https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123883
Dusan Stojkovic <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #1 from Dusan Stojkovic <[email protected]> --- Created attachment 64155 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=64155&action=edit Proposed Patch Hello, So this match.pd pattern > (simplify > (bit_and (convert? (lshift integer_onep@1 SSA_NAME@0)) (convert? (lshift > integer_onep SSA_NAME@0))) > (lshift (convert @1) (convert @0))) results in the following assembly when compiled with -O2 rv64gcb: lbu a5,0(a0) li a4,1 sllw a4,a4,a1 bclr a5,a5,a1 or a5,a5,a4 sb a5,0(a0) ret Looking at the combine dump after applying the match.pd change, there is this attempt to combine: Trying 18, 19, 15 -> 23: 18: r156:SI=0x1 19: r157:DI=sign_extend(r156:SI<<r143:DI#0) REG_DEAD r143:DI REG_DEAD r156:SI 15: r152:DI=0xfffffffffffffffe<-<r143:DI#0&r151:DI REG_DEAD r151:DI 23: r160:DI=r152:DI|r157:DI REG_DEAD r157:DI REG_DEAD r152:DI Failed to match this instruction: (set (reg:DI 160) (ior:DI (and:DI (rotate:DI (const_int -2 [0xfffffffffffffffe]) (subreg:QI (reg/v:DI 143 [ lo_bit ]) 0)) (reg:DI 151 [ *data_10(D) ])) (sign_extend:DI (ashift:SI (const_int 1 [0x1]) (subreg:QI (reg/v:DI 143 [ lo_bit ]) 0))))) For which the bitmanip.md pattern attached in patch.txt combined with the match.pd pattern produce the following assembly: lbu a5,0(a0) bset a5,a5,a1 sb a5,0(a0) ret
