> A while ago I've tried doing that for SH (implementing bswap16 with RTL > combine). It was like an explosion of patterns, because combine would > try out a lot of things depending on the surrounding code around the > actual bswap16. In the end I decided to drop that stuff for the most > part.
OK, thanks for your feedback. Note that you won't get the benefit of the optimization for SH if you don't define a bswaphi2 pattern. > BTW, the built-in documentation says: > > Built-in Function: int16_t __builtin_bswap16 (int16_t x) > Built-in Function: int32_t __builtin_bswap32 (int32_t x) > > However, it seems the result is always unsigned for those. Yes, builtins.def contains: DEF_GCC_BUILTIN (BUILT_IN_BSWAP16, "bswap16", BT_FN_UINT16_UINT16, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_GCC_BUILTIN (BUILT_IN_BSWAP32, "bswap32", BT_FN_UINT32_UINT32, ATTR_CONST_NOTHROW_LEAF_LIST) DEF_GCC_BUILTIN (BUILT_IN_BSWAP64, "bswap64", BT_FN_UINT64_UINT64, ATTR_CONST_NOTHROW_LEAF_LIST) The documentation indeed needs to be fixed. -- Eric Botcazou