Hi All, 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. Bootstrapped Regtested on aarch64-none-linux-gnu, arm-none-linux-gnueabihf, x86_64-pc-linux-gnu -m32, -m64 and no issues. Ok for master? 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. --- diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 501c6d8a54dbc97e4cd6f6804bb11c2411cc4129..f9f7f4d2f917235a2ffef67c363b3cfb8c1694f9 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -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 index 0000000000000000000000000000000000000000..dd842a6ae0fedd7e5e1505bb846267eb25e3e14a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr118472.c @@ -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]; + } +} --
diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 501c6d8a54dbc97e4cd6f6804bb11c2411cc4129..f9f7f4d2f917235a2ffef67c363b3cfb8c1694f9 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -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 index 0000000000000000000000000000000000000000..dd842a6ae0fedd7e5e1505bb846267eb25e3e14a --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr118472.c @@ -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]; + } +}