]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
AArch64: Add movi for 0 moves for scalar types [PR109154]
authorTamar Christina <tamar.christina@arm.com>
Thu, 9 Nov 2023 14:03:04 +0000 (14:03 +0000)
committerTamar Christina <tamar.christina@arm.com>
Thu, 9 Nov 2023 14:07:43 +0000 (14:07 +0000)
Following the Neoverse N/V and Cortex-A optimization guides SIMD 0 immediates
should be created with a movi of 0.

At the moment we generate an `fmov .., xzr` which is slower and requires a
GP -> FP transfer.

gcc/ChangeLog:

PR tree-optimization/109154
* config/aarch64/aarch64.md (*mov<mode>_aarch64, *movsi_aarch64,
*movdi_aarch64): Add new w -> Z case.
* config/aarch64/iterators.md (Vbtype): Add QI and HI.

gcc/testsuite/ChangeLog:

PR tree-optimization/109154
* gcc.target/aarch64/fneg-abs_2.c: Updated.
* gcc.target/aarch64/fneg-abs_4.c: Updated.
* gcc.target/aarch64/dbl_mov_immediate_1.c: Updated.

gcc/config/aarch64/aarch64.md
gcc/config/aarch64/iterators.md
gcc/testsuite/gcc.target/aarch64/dbl_mov_immediate_1.c
gcc/testsuite/gcc.target/aarch64/fneg-abs_2.c
gcc/testsuite/gcc.target/aarch64/fneg-abs_4.c

index 5d1e0f8a51aa53ffa0504d26685fab9dcfc6b96b..4fcd71a2e9d1e8c35f35593255c4f66a68856a79 100644 (file)
   "(register_operand (operands[0], <MODE>mode)
     || aarch64_reg_or_zero (operands[1], <MODE>mode))"
   {@ [cons: =0, 1; attrs: type, arch]
+     [w, Z    ; neon_move      , simd  ] movi\t%0.<Vbtype>, #0
      [r, r    ; mov_reg        , *     ] mov\t%w0, %w1
      [r, M    ; mov_imm        , *     ] mov\t%w0, %1
      [w, D<hq>; neon_move      , simd  ] << aarch64_output_scalar_simd_mov_immediate (operands[1], <MODE>mode);
   "(register_operand (operands[0], SImode)
     || aarch64_reg_or_zero (operands[1], SImode))"
   {@ [cons: =0, 1; attrs: type, arch, length]
+     [w  , Z  ; neon_move, simd, 4] movi\t%0.2d, #0
      [r k, r  ; mov_reg  , *   , 4] mov\t%w0, %w1
      [r  , k  ; mov_reg  , *   , 4] ^
      [r  , M  ; mov_imm  , *   , 4] mov\t%w0, %1
   "(register_operand (operands[0], DImode)
     || aarch64_reg_or_zero (operands[1], DImode))"
   {@ [cons: =0, 1; attrs: type, arch, length]
+     [w, Z  ; neon_move, simd, 4] movi\t%0.2d, #0
      [r, r  ; mov_reg  , *   , 4] mov\t%x0, %x1
      [k, r  ; mov_reg  , *   , 4] mov\t%0, %x1
      [r, k  ; mov_reg  , *   , 4] mov\t%x0, %1
index f9e2210095ea9d6d9c96971222a7757a2f418c2d..1593a8fd04f91259295d0e393cbc7973daf7bf73 100644 (file)
                          (V4SF "16b") (V2DF  "16b")
                          (DI   "8b")  (DF    "8b")
                          (SI   "8b")  (SF    "8b")
+                         (QI   "8b")  (HI    "8b")
                          (V4BF "8b")  (V8BF  "16b")])
 
 ;; Advanced SIMD vector structure to element modes.
index fb9088e9d2849c0ea10a8741795181a0543c3cb2..4838f74d052eec235f78a5f27d3a3651ce2ae2fe 100644 (file)
@@ -49,7 +49,7 @@ double d4(void)
 /* { dg-final { scan-assembler-times "mov\tx\[0-9\]+, 25838523252736"       1 } } */
 /* { dg-final { scan-assembler-times "movk\tx\[0-9\]+, 0x40fe, lsl 48"      1 } } */
 /* { dg-final { scan-assembler-times "mov\tx\[0-9\]+, -9223372036854775808" 0 } } */
-/* { dg-final { scan-assembler-times {movi\tv[0-9]+.2d, #0} 1 } } */
+/* { dg-final { scan-assembler-times {movi\tv[0-9]+.4s, #?0} 1 } } */
 /* { dg-final { scan-assembler-times {fneg\tv[0-9]+.2d, v[0-9]+.2d} 1 } } */
 /* { dg-final { scan-assembler-times "fmov\td\[0-9\]+, x\[0-9\]+"           1 } } */
 
index fb14ec3e2210e0feeff80f2410d777d3046a9f78..eed41ea18e69ff60ac79cbdb7c0c935850b49b33 100644 (file)
@@ -20,7 +20,7 @@ float32_t f1 (float32_t a)
 
 /*
 ** f2:
-**     fmov    d[0-9]+, xzr
+**     movi    v[0-9]+.4s, #?0
 **     fneg    v[0-9]+.2d, v[0-9]+.2d
 **     orr     v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b
 **     ret
index 4ea0105f6c0a9756070bcc60d34f142f53d8242c..d45c3d1210c682f38177a89f1137ab4f6decfbc1 100644 (file)
@@ -8,7 +8,7 @@
 
 /*
 ** negabs:
-**     fmov    d[0-9]+, xzr
+**     movi    v31.4s, #?0
 **     fneg    v[0-9]+.2d, v[0-9]+.2d
 **     orr     v[0-9]+.8b, v[0-9]+.8b, v[0-9]+.8b
 **     ret