https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115102
Oleg Endo <olegendo at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Last reconfirmed| |2024-05-15 Status|UNCONFIRMED |NEW --- Comment #2 from Oleg Endo <olegendo at gcc dot gnu.org> --- (In reply to Richard Biener from comment #1) > I believe this might be the middle-end using bswap32 (you can try to confirm > for SH by looking at the dump generated by -fdump-tree-optimized). > Haven't checked the tree dump, but combine log shows patterns with 'bswap-something' in it. And the patterns that it tries to match are some sort of partial bswaps. On SH there is already a pattern: (define_insn "swapbsi2" [(set (match_operand:SI 0 "arith_reg_dest" "=r") (ior:SI (and:SI (match_operand:SI 1 "arith_reg_operand" "r") (const_int -65536)) ;; 0xFFFF0000 (ior:SI (and:SI (ashift:SI (match_dup 1) (const_int 8)) (const_int 65280)) (and:SI (ashiftrt:SI (match_dup 1) (const_int 8)) (const_int 255)))))] But combine doesn't arrive there and it stops at the intermediate combine bridge pattern (define_insn_and_split "*swapbisi2_and_shl8" [(set (match_operand:SI 0 "arith_reg_dest" "=r") (ior:SI (and:SI (ashift:SI (match_operand:SI 1 "arith_reg_operand" "r") (const_int 8)) (const_int 65280)) (match_operand:SI 2 "arith_reg_operand" "r")))] Adding another variant of the existing pattern, which combine is looking for, helps in this case: (define_insn "*swapbisi2" [(set (match_operand:SI 0 "arith_reg_dest" "=r") (ior:SI (ior:SI (and:SI (ashift:SI (match_operatnd:SI 1 "arith_reg_operand" "r") (const_int 8)) (const_int 65280)) (and:SI (lshiftrt:SI (match_dup 1) (const_int 8)) (const_int 255))) (and:SI (match_dup 1) (const_int -65536))))] I haven't checked if the original pattern is still used in other cases or not.