aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Lyon <christophe.lyon@linaro.org>2024-03-15 19:55:43 +0000
committerChristophe Lyon <christophe.lyon@linaro.org>2024-03-19 08:19:08 +0000
commit167ec6df7fd8deb67759acd5dbe72c1982a55873 (patch)
treefc0a0c965daae20f91b396f8823913d072d62764
parenta185d8aeeed7a25a01505565aa61ccf8a876c6ff (diff)
downloadgcc-167ec6df7fd8deb67759acd5dbe72c1982a55873.zip
gcc-167ec6df7fd8deb67759acd5dbe72c1982a55873.tar.gz
gcc-167ec6df7fd8deb67759acd5dbe72c1982a55873.tar.bz2
arm: [MVE intrinsics] Fix support for loads [PR target/114323]
The testcase in this PR shows that we would load from an uninitialized location, because the vld1 instrinsics are reported as "const". This is because function_instance::reads_global_state_p() does not take CP_READ_MEMORY into account. Fixing this gives vld1 the "pure" attribute instead, and solves the problem. 2024-03-15 Christophe Lyon <christophe.lyon@linaro.org> PR target/114323 gcc/ * config/arm/arm-mve-builtins.cc (function_instance::reads_global_state_p): Take CP_READ_MEMORY into account. gcc/testsuite/ * gcc.target/arm/mve/pr114323.c: New.
-rw-r--r--gcc/config/arm/arm-mve-builtins.cc2
-rw-r--r--gcc/testsuite/gcc.target/arm/mve/pr114323.c22
2 files changed, 23 insertions, 1 deletions
diff --git a/gcc/config/arm/arm-mve-builtins.cc b/gcc/config/arm/arm-mve-builtins.cc
index c533d0e..7e82176 100644
--- a/gcc/config/arm/arm-mve-builtins.cc
+++ b/gcc/config/arm/arm-mve-builtins.cc
@@ -657,7 +657,7 @@ function_instance::reads_global_state_p () const
if (flags & CP_READ_FPCR)
return true;
- return false;
+ return flags & CP_READ_MEMORY;
}
/* Return true if calls to the function could modify some form of
diff --git a/gcc/testsuite/gcc.target/arm/mve/pr114323.c b/gcc/testsuite/gcc.target/arm/mve/pr114323.c
new file mode 100644
index 0000000..bd9127b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arm/mve/pr114323.c
@@ -0,0 +1,22 @@
+/* { dg-do run } */
+/* { dg-require-effective-target arm_mve_hw } */
+/* { dg-options "-O2" } */
+/* { dg-add-options arm_v8_1m_mve_fp } */
+
+#include <arm_mve.h>
+
+__attribute__((noipa))
+uint32x4_t foo (void) {
+ uint32x4_t V0 = vld1q_u32(((const uint32_t[4]){1, 2, 3, 4}));
+ return V0;
+}
+
+int main(void)
+{
+ uint32_t buf[4];
+ vst1q_u32 (buf, foo());
+
+ for (int i = 0; i < 4; i++)
+ if (buf[i] != i+1)
+ __builtin_abort ();
+}