(define_expand "bswapsi2"
[(set (match_operand:SI 0 "register_operand")
(bswap:SI (match_operand:SI 1 "register_operand")))]
- "TARGET_ZBB || TARGET_ZBKB || TARGET_XTHEADBB"
-{
- /* Expose bswapsi2 on TARGET_64BIT so that the gimple store
- merging pass will create suitable bswap insns. We can actually
- just FAIL that case when generating RTL and let the generic code
- handle it. */
- if (TARGET_64BIT && !TARGET_XTHEADBB)
- FAIL;
-})
-
+ "(!TARGET_64BIT && (TARGET_ZBB || TARGET_ZBKB)) || TARGET_XTHEADBB")
(define_insn "*bswap<mode>2"
[(set (match_operand:X 0 "register_operand" "=r")
break;
case 32:
if (builtin_decl_explicit_p (BUILT_IN_BSWAP32)
- && optab_handler (bswap_optab, SImode) != CODE_FOR_nothing)
+ && (optab_handler (bswap_optab, SImode) != CODE_FOR_nothing
+ /* widen_bswap_or_bitreverse can implement 32-bit bswap
+ using bswapdi2 and shift. */
+ || optab_handler (bswap_optab, DImode) != CODE_FOR_nothing))
{
load_type = uint32_type_node;
fndecl = builtin_decl_explicit (BUILT_IN_BSWAP32);
case 64:
if (builtin_decl_explicit_p (BUILT_IN_BSWAP64)
&& (optab_handler (bswap_optab, DImode) != CODE_FOR_nothing
+ /* expand_doubleword_bswap_or_bitreverse can use 2 bswapsi2
+ expanders on 32-bit targets. */
|| (word_mode == SImode
&& builtin_decl_explicit_p (BUILT_IN_BSWAP32)
&& optab_handler (bswap_optab, SImode) != CODE_FOR_nothing)))
tree bswap32_type = NULL_TREE, bswap64_type = NULL_TREE;
bswap32_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP32)
- && optab_handler (bswap_optab, SImode) != CODE_FOR_nothing);
+ && (optab_handler (bswap_optab, SImode) != CODE_FOR_nothing
+ /* widen_bswap_or_bitreverse can implement 32-bit bswap
+ using bswapdi2 and shift. */
+ || (optab_handler (bswap_optab, DImode)
+ != CODE_FOR_nothing)));
bswap64_p = (builtin_decl_explicit_p (BUILT_IN_BSWAP64)
&& (optab_handler (bswap_optab, DImode) != CODE_FOR_nothing
+ /* expand_doubleword_bswap_or_bitreverse can use 2 bswapsi2
+ expanders on 32-bit targets. */
|| (bswap32_p && word_mode == SImode)));
/* Determine the argument type of the builtins. The code later on