]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
middle-end: Fix incorrect type replacement in operands_equals [PR118472]
authorTamar Christina <tamar.christina@arm.com>
Wed, 15 Jan 2025 13:58:00 +0000 (13:58 +0000)
committerTamar Christina <tamar.christina@arm.com>
Wed, 15 Jan 2025 13:58:00 +0000 (13:58 +0000)
In g:3c32575e5b6370270d38a80a7fa8eaa144e083d0 I made a mistake and incorrectly
replaced the type of the arguments of an expression with the type of the
expression.  This is of course wrong.

This reverts that change and I have also double checked the other replacements
and they are fine.

gcc/ChangeLog:

PR middle-end/118472
* fold-const.cc (operand_compare::operand_equal_p): Fix incorrect
replacement.

gcc/testsuite/ChangeLog:

PR middle-end/118472
* gcc.dg/pr118472.c: New test.

gcc/fold-const.cc
gcc/testsuite/gcc.dg/pr118472.c [new file with mode: 0644]

index 501c6d8a54dbc97e4cd6f6804bb11c2411cc4129..f9f7f4d2f917235a2ffef67c363b3cfb8c1694f9 100644 (file)
@@ -3746,7 +3746,8 @@ operand_compare::operand_equal_p (tree type0, const_tree arg0,
             of op1.  Need to check to make sure they are the same.  */
          if (TREE_CODE (TREE_OPERAND (arg0, 1)) == INTEGER_CST
              && TREE_CODE (TREE_OPERAND (arg1, 1)) == INTEGER_CST
-             && TYPE_PRECISION (type0) != TYPE_PRECISION (type1))
+             && TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (arg0, 1)))
+                   != TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (arg1, 1))))
            return false;
          /* FALLTHRU */
 
diff --git a/gcc/testsuite/gcc.dg/pr118472.c b/gcc/testsuite/gcc.dg/pr118472.c
new file mode 100644 (file)
index 0000000..dd842a6
--- /dev/null
@@ -0,0 +1,32 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -fopenmp-simd" } */
+
+typedef int a;
+typedef struct {
+  a b __attribute__((__vector_size__(8)));
+} c;
+
+typedef a d __attribute__((__vector_size__(8)));
+c e, f, g;
+d h, j;
+void k() {
+  c l;
+  l.b[1] = 0;
+  c m = l;
+  __builtin_memcpy(&h, &m, sizeof(h));
+  j = h;
+  {
+    c l;
+    l.b[1] = 0;
+    m = l;
+    __builtin_memcpy(&h, &m, sizeof(h));
+    d m = j;
+    __builtin_memcpy(&g, &m, sizeof(g));
+    e = g;
+    m = h;
+    __builtin_memcpy(&g, &m, sizeof(g));
+#pragma omp simd
+    for (long i = 0; i < f.b[0]; i++)
+      f.b[i] = e.b[i] > g.b[i];
+  }
+}