| Summary: | uClibc should use __builtin_bswap{32,64} on at least some archs | ||
|---|---|---|---|
| Product: | uClibc | Reporter: | Peter Collingbourne <peter> |
| Component: | Other | Assignee: | unassigned |
| Status: | NEW --- | ||
| Severity: | normal | CC: | uclibc-cvs |
| Priority: | P5 | ||
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Host: | Target: | ||
| Build: | |||
| Attachments: | [PATCH] byteswap: use compiler builtins if available | ||
IIRC you should get a bswap pass in -fexpensive-optimizations Comment on attachment 2665 [details]
[PATCH] byteswap: use compiler builtins if available
i don't think it should be blindly overriding the arch code. using the builtins should be done only if the arch hasn't selected it.
look at glibc's bits/byteswap.h.
|
Created attachment 2665 [details] [PATCH] byteswap: use compiler builtins if available GCC has provided the builtins __builtin_bswap32 and __builtin_bswap64 since 4.2. If we have a sufficient GCC version, we should use the builtins instead of our own implementation. This allows the compiler to apply optimisations (e.g. bswap(bswap(x)) = x). Attached is a patch which should act as a starting point. One issue to be decided: on which architectures should we use the builtin? The patch uses the builtin on all architectures, but looking through the gcc source code it appears that the set of optimised bswap implementations overlaps but differs between gcc and uClibc. gcc covers all the major architectures though, so this may not be such a crucial point.