[PATCH] Fix PR82320

Richard Biener rguenther@suse.de
Tue Sep 26 07:30:00 GMT 2017


Bootstrapped and tested on x86_64-unkown-linux-gnu, applied.

Richard.

2017-09-26  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/82320
	* tree-ssa-sccvn.c (set_ssa_val_to): Changing undef to undef
	isn't a change.

	* gcc.dg/torture/pr82320.c: New testcase.

Index: gcc/tree-ssa-sccvn.c
===================================================================
--- gcc/tree-ssa-sccvn.c	(revision 253149)
+++ gcc/tree-ssa-sccvn.c	(working copy)
@@ -3355,6 +3355,12 @@ set_ssa_val_to (tree from, tree to)
 
   if (currval != to
       && !operand_equal_p (currval, to, 0)
+      /* Different undefined SSA names are not actually different.  See
+         PR82320 for a testcase were we'd otherwise not terminate iteration.  */
+      && !(TREE_CODE (currval) == SSA_NAME
+	   && TREE_CODE (to) == SSA_NAME
+	   && ssa_undefined_value_p (currval, false)
+	   && ssa_undefined_value_p (to, false))
       /* ???  For addresses involving volatile objects or types operand_equal_p
          does not reliably detect ADDR_EXPRs as equal.  We know we are only
 	 getting invariant gimple addresses here, so can use
Index: gcc/testsuite/gcc.dg/torture/pr82320.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr82320.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr82320.c	(working copy)
@@ -0,0 +1,39 @@
+/* { dg-do compile } */
+
+void
+ec (int n4, short int ea)
+{
+  if (1)
+    {
+      if (ea != 0)
+	{
+	  int *c1 = (int *)&ea;
+
+nn:
+	  for (;;)
+	    ++*c1;
+	}
+    }
+  else
+    {
+      int *lq = &n4;
+      int *md;
+      int da;
+
+      goto nn;
+
+r1:
+      md = lq;
+      for (da = 0; da < 1; ++da)
+	{
+ig:
+	  ++n4;
+	  *md += n4;
+	}
+    }
+
+  for (ea = 0; ea < 1; ++ea)
+    goto r1;
+
+  goto ig;
+}



More information about the Gcc-patches mailing list