]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add a REG_P check for inc and dec for Arm MVE
authorSaurabh Jha <saurabh.jha@arm.com>
Tue, 14 Nov 2023 14:48:40 +0000 (14:48 +0000)
committerKyrylo Tkachov <kyrylo.tkachov@arm.com>
Tue, 14 Nov 2023 14:49:46 +0000 (14:49 +0000)
This patch tightens mve_vector_mem_operand to reject non-register operands inside {PRE,POST}_{INC,DEC} addresses by introducing a REG_P check.

This patch fixes this ICE:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=112337

gcc/ChangeLog:

PR target/112337
* config/arm/arm.cc (mve_vector_mem_operand): Add a REG_P check for INC
and DEC operations.

gcc/testsuite/ChangeLog:

PR target/112337
* gcc.target/arm/mve/pr112337.c: Test for REG_P check for INC and DEC
operations.

gcc/config/arm/arm.cc
gcc/testsuite/gcc.target/arm/mve/pr112337.c [new file with mode: 0644]

index 620ef7bfb2f3af9b8de576359a6157190c439aad..25a1ad736ad96f0cb18b063fec29a09c4cfdbd1d 100644 (file)
@@ -13695,8 +13695,11 @@ mve_vector_mem_operand (machine_mode mode, rtx op, bool strict)
     }
   code = GET_CODE (op);
 
-  if (code == POST_INC || code == PRE_DEC
-      || code == PRE_INC || code == POST_DEC)
+  if ((code == POST_INC
+       || code == PRE_DEC
+       || code == PRE_INC
+       || code == POST_DEC)
+      && REG_P (XEXP (op, 0)))
     {
       reg_no = arm_effective_regno (XEXP (op, 0), strict);
       return (((mode == E_V8QImode || mode == E_V4QImode || mode == E_V4HImode)
diff --git a/gcc/testsuite/gcc.target/arm/mve/pr112337.c b/gcc/testsuite/gcc.target/arm/mve/pr112337.c
new file mode 100644 (file)
index 0000000..8f49199
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-require-effective-target arm_v8_1m_mve_ok } */
+/* { dg-add-options arm_v8_1m_mve } */
+#include <arm_mve.h>
+
+void g(int32x4_t);
+void f(int, int, int, short, int *p) {
+  int *bias = p;
+  for (;;) {
+    int32x4_t d = vldrwq_s32 (p);
+    bias += 4;
+    g(d);
+  }
+}