This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR87700
- From: Richard Biener <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 23 Oct 2018 11:33:15 +0200 (CEST)
- Subject: [PATCH] Fix PR87700
This fixes a very old bug in the copy-propagation lattice-update
exposed by my SSA propagator changes which happen to introduce
oscillation between two unshared ADDR_EXPRs.
Bootstrapped and tested on x86_64-unknown-linux-gnu, applied to trunk
and branch.
Richard.
2018-10-23 Richard Biener <rguenther@suse.de>
PR tree-optimization/87700
* tree-ssa-copy.c (set_copy_of_val): Fix change detection logic.
* gcc.dg/torture/pr87700.c: New testcase.
Index: gcc/tree-ssa-copy.c
===================================================================
--- gcc/tree-ssa-copy.c (revision 265192)
+++ gcc/tree-ssa-copy.c (working copy)
@@ -155,7 +155,7 @@ set_copy_of_val (tree var, tree val)
copy_of[ver].value = val;
if (old != val
- || (val && !operand_equal_p (old, val, 0)))
+ && (!old || !operand_equal_p (old, val, 0)))
return true;
return false;
Index: gcc/testsuite/gcc.dg/torture/pr87700.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr87700.c (nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr87700.c (working copy)
@@ -0,0 +1,49 @@
+/* { dg-do compile } */
+
+void
+wn (int ki)
+{
+ int m8 = 0;
+ int *d6 = &ki;
+
+ if (ki == 0)
+ {
+ud:
+ for (ki = 0; ki < 1; ++ki)
+ for (m8 = 0; m8 < 1; ++m8)
+ goto ud;
+
+ d6 = &m8;
+
+y8:
+ ++m8;
+
+xw:
+ if (ki == 0)
+ {
+ }
+ else
+ {
+ for (m8 = 0; m8 < 1; ++m8)
+ {
+gt:
+ if (*d6 == 0)
+ goto y8;
+ }
+
+ for (m8 = 0; m8 < 1; ++m8)
+ {
+ goto gt;
+
+ym:
+ ;
+ }
+ }
+
+ d6 = &ki;
+
+ goto ym;
+ }
+
+ goto xw;
+}