https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89954
--- Comment #10 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Hongtao.liu from comment #9) > (In reply to Hongtao.liu from comment #8) > > (In reply to Uroš Bizjak from comment #7) > > > Created attachment 51496 [details] > > > Prototype patch > > > > +;; convert (sign_extend:WIDE (any_logic:NARROW (memory, immediate))) > > +;; to (any_logic:WIDE (sign_extend (memory)), (sign_extend (immediate))). > > +;; This eliminates sign extension after logic operation. > > + > > +(define_split > > + [(set (match_operand:SWI248 0 "register_operand") > > + (sign_extend:SWI248 > > + (any_logic:QI (match_operand:QI 1 "memory_operand") > > + (match_operand:QI 2 "const_int_operand"))))] > > + "" > > + [(set (match_dup 0) (any_logic:SWI248 (match_dup 0) (match_dup 2)))] > > + "convert_move (operands[0], operands[1], false);") > > > > Shouldn't we make sure (any_logic op1 const_int) would change sign bit of > > op1? > Typo, would not change sign bit of op1. It doesn't matter, since all constants are implicitly sign-extended by the insn. For example, convert sext:HI (xor:QI (op1, -1)) to xor:HI (sext:HI (op1), -1): (a = op1, b = -1) sext:HI (xor:QI (op1, -1)): a 0xxxxxxx b 1xxxxxxx r 11111111 1xxxxxxx a 1xxxxxxx b 1xxxxxxx r 00000000 0xxxxxxx xor:HI (sext:HI (op1), -1): a 00000000 0xxxxxxx b 11111111 1xxxxxxx r 11111111 1xxxxxxx a 11111111 1xxxxxxx b 11111111 1xxxxxxx r 00000000 0xxxxxxx