]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
aarch64: Fix aarch64_ldp_reg_operand predicate not to allow all subreg [PR113221]
authorAndrew Pinski <quic_apinski@quicinc.com>
Tue, 16 Jan 2024 23:37:49 +0000 (15:37 -0800)
committerAndrew Pinski <quic_apinski@quicinc.com>
Wed, 17 Jan 2024 22:03:19 +0000 (14:03 -0800)
So the problem here is that aarch64_ldp_reg_operand will all subreg even subreg of lo_sum.
When LRA tries to fix that up, all things break. So the fix is to change the check to only
allow reg and subreg of regs.

Note the tendancy here is to use register_operand but that checks the mode of the register
but we need to allow a mismatch modes for this predicate for now.

Built and tested for aarch64-linux-gnu with no regressions
(Also tested with the LD/ST pair pass back on).

PR target/113221

gcc/ChangeLog:

* config/aarch64/predicates.md (aarch64_ldp_reg_operand): For subreg,
only allow REG operands instead of allowing all.

gcc/testsuite/ChangeLog:

* gcc.c-torture/compile/pr113221-1.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/config/aarch64/predicates.md
gcc/testsuite/gcc.c-torture/compile/pr113221-1.c [new file with mode: 0644]

index 8a204e48bb53edc08887c66620cbe4d6c2aaf68b..b895f5dcb867abd67d24cf7beaec90523aef17e1 100644 (file)
 
 (define_special_predicate "aarch64_ldp_reg_operand"
   (and
-    (match_code "reg,subreg")
+    (ior
+      (match_code "reg")
+      (and
+       (match_code "subreg")
+       (match_test "REG_P (SUBREG_REG (op))")))
     (match_test "aarch64_ldpstp_operand_mode_p (GET_MODE (op))")
     (ior
       (match_test "mode == VOIDmode")
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr113221-1.c b/gcc/testsuite/gcc.c-torture/compile/pr113221-1.c
new file mode 100644 (file)
index 0000000..942fa5e
--- /dev/null
@@ -0,0 +1,12 @@
+/* { dg-options "-fno-move-loop-invariants -funroll-all-loops" } */
+/* PR target/113221 */
+/* This used to ICE after the `load/store pair fusion pass` was added
+   due to the predicate aarch64_ldp_reg_operand allowing too much. */
+
+
+void bar();
+void foo(int* b) {
+  for (;;)
+    *b++ = (__SIZE_TYPE__)bar;
+}
+