aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2022-10-06 11:20:16 +0200
committerRichard Biener <rguenther@suse.de>2022-10-06 12:07:21 +0200
commit85333b9265720fc4e49397301cb16324d2b89aa7 (patch)
treea0d49cc7eb2e1284a5d04b0b44393cba1aca22ea /gcc/testsuite
parent544d14e1b42eeb337fcefb1efe9d108e71a06d52 (diff)
downloadgcc-85333b9265720fc4e49397301cb16324d2b89aa7.zip
gcc-85333b9265720fc4e49397301cb16324d2b89aa7.tar.gz
gcc-85333b9265720fc4e49397301cb16324d2b89aa7.tar.bz2
tree-optimization/107107 - tail-merging VN wrong-code
The following fixes an unintended(?) side-effect of the special MODIFY_EXPR expression entries we add for tail-merging during VN. We shouldn't value-number the virtual operand differently here. PR tree-optimization/107107 * tree-ssa-sccvn.cc (visit_reference_op_store): Do not affect value-numbering when doing the tail merging MODIFY_EXPR lookup. * gcc.dg/pr107107.c: New testcase.
Diffstat (limited to 'gcc/testsuite')
-rw-r--r--gcc/testsuite/gcc.dg/pr107107.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/pr107107.c b/gcc/testsuite/gcc.dg/pr107107.c
new file mode 100644
index 0000000..5ad6a63
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/pr107107.c
@@ -0,0 +1,25 @@
+/* { dg-do run } */
+/* { dg-options "-O2 -ftree-tail-merge" } */
+
+static inline void set_longish(int is_long_long, void *p, long x)
+{
+ if (is_long_long)
+ *(long long*)p = x;
+ else
+ *(long*)p = x;
+}
+static long test(long long *p, int index, int mode)
+{
+ *p = 1;
+ set_longish(mode, p+index, 2);
+ return *p;
+}
+long (*volatile vtest)(long long*, int, int) = test;
+int main(void)
+{
+ long long x;
+ long result = vtest(&x, 0, 1);
+ if (result != 2 || x != 2)
+ __builtin_abort ();
+ return 0;
+}