Jakub Jelinek <ja...@redhat.com> writes: > --- gcc/config/aarch64/aarch64.md.jj 2021-04-15 10:45:02.798853095 +0200 > +++ gcc/config/aarch64/aarch64.md 2021-04-15 13:28:04.734754364 +0200 > @@ -3572,6 +3572,18 @@ (define_insn "*neg_<shift>_si2_uxtw" > [(set_attr "autodetect_type" "alu_shift_<shift>_op2")] > ) > > +(define_insn "*neg_asr_si2_extr" > + [(set (match_operand:SI 0 "register_operand" "r") > + (neg:SI (match_operator 4 "subreg_lowpart_operator"
Very minor, but it might be better to have the :SI on the match_operator too, like in the pattern below. > + [(sign_extract:DI > + (match_operand:DI 1 "register_operand" "r") > + (match_operand 3 "aarch64_simd_shift_imm_offset_si" "n") > + (match_operand 2 "aarch64_simd_shift_imm_offset_si" > "n"))])))] > + "INTVAL (operands[2]) + INTVAL (operands[3]) == 32" > + "neg\\t%w0, %w1, asr %2" > + [(set_attr "autodetect_type" "alu_shift_asr_op2")] > +) > + > (define_insn "mul<mode>3" > [(set (match_operand:GPI 0 "register_operand" "=r") > (mult:GPI (match_operand:GPI 1 "register_operand" "r") > @@ -5382,6 +5394,22 @@ (define_insn "*extrsi5_insn_uxtw_alt" > "extr\\t%w0, %w1, %w2, %4" > [(set_attr "type" "rotate_imm")] > ) > + > +(define_insn "*extrsi5_insn_di" > + [(set (match_operand:SI 0 "register_operand" "=r") > + (ior:SI (ashift:SI (match_operand:SI 1 "register_operand" "r") > + (match_operand 3 "const_int_operand" "n")) > + (match_operator:SI 6 "subreg_lowpart_operator" > + [(zero_extract:DI > + (match_operand:DI 2 "register_operand" "r") > + (match_operand 5 "const_int_operand" "n") > + (match_operand 4 "const_int_operand" "n"))])))] > + "UINTVAL (operands[3]) < 32 > + && UINTVAL (operands[3]) + UINTVAL (operands[4]) == 32 > + && UINTVAL (operands[4]) + UINTVAL (operands[5]) - 32 <= 64" Could you explain this condition? With operand 5 being the size and operand 4 being the position, I was expecting something like: "UINTVAL (operands[3]) < 32 && UINTVAL (operands[3]) == UINTVAL (operands[5]) && UINTVAL (operands[4]) + UINTVAL (operands[5]) == 32" i.e. the %w1 shift must equal the size of the %w2 extraction and the %w2 extraction must align with the top of the register. Or, writing it in more the style of the original condition, the final line would be: && UINTVAL (operands[3]) == UINTVAL (operands[5])" instead of: && UINTVAL (operands[4]) + UINTVAL (operands[5]) - 32 <= 64" Not tested though, and it's late, so I could have got that completely wrong :-) Thanks, Richard > + "extr\\t%w0, %w1, %w2, %4" > + [(set_attr "type" "rotate_imm")] > +) > > (define_insn "*ror<mode>3_insn" > [(set (match_operand:GPI 0 "register_operand" "=r") > --- gcc/testsuite/gcc.target/aarch64/pr100075.c.jj 2021-04-15 > 13:23:31.188852983 +0200 > +++ gcc/testsuite/gcc.target/aarch64/pr100075.c 2021-04-15 > 13:23:10.612086048 +0200 > @@ -0,0 +1,20 @@ > +/* PR target/100075 */ > +/* { dg-do compile } */ > +/* { dg-options "-O2" } */ > +/* { dg-final { scan-assembler-not {\tsbfx\tx[0-9]+, x[0-9]+, 16, 16} } } */ > +/* { dg-final { scan-assembler {\tneg\tw[0-9]+, w[0-9]+, asr 16} } } */ > +/* { dg-final { scan-assembler {\textr\tw[0-9]+, w[0-9]+, w[0-9]+, 16} } } */ > + > +struct S { short x, y; }; > + > +struct S > +f1 (struct S p) > +{ > + return (struct S) { -p.y, p.x }; > +} > + > +struct S > +f2 (struct S p) > +{ > + return (struct S) { p.y, -p.x }; > +} > > Jakub