Fix PR91200

Message ID alpine.LSU.2.20.1907191422530.30921@zhemvz.fhfr.qr
State New
Headers show
Series
  • Fix PR91200
Related show

Commit Message

Richard Biener July 19, 2019, 12:23 p.m.
The following fixes cselim.

Bootstrapped/tested on x86_64-unknown-linux-gnu, applied.

Richard.

2019-07-19  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/91200
	* tree-ssa-phiopt.c (cond_store_replacement): Check we have
	no PHI nodes in middle-bb.

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

Patch

Index: gcc/tree-ssa-phiopt.c
===================================================================
--- gcc/tree-ssa-phiopt.c	(revision 273590)
+++ gcc/tree-ssa-phiopt.c	(working copy)
@@ -2216,6 +2216,11 @@  cond_store_replacement (basic_block midd
       || gimple_has_volatile_ops (assign))
     return false;
 
+  /* And no PHI nodes so all uses in the single stmt are also
+     available where we insert to.  */
+  if (!gimple_seq_empty_p (phi_nodes (middle_bb)))
+    return false;
+
   locus = gimple_location (assign);
   lhs = gimple_assign_lhs (assign);
   rhs = gimple_assign_rhs1 (assign);
Index: gcc/testsuite/gcc.dg/torture/pr91200.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr91200.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/torture/pr91200.c	(working copy)
@@ -0,0 +1,32 @@ 
+/* { dg-do compile } */
+
+int printf (const char *, ...);
+
+char a;
+int b, c, **d;
+
+int main ()
+{
+  int f = -128, *g, *h[2] = {0, 0}, i;
+  printf("0");
+  if (a)
+    {
+      while (f > a) {
+        int *j = &i;
+        *j |= 0;
+      }
+      h[i] = &c;
+    }
+  if (h[1])
+    {
+      int **k = &g;
+      *k = &f;
+      while (i)
+        {
+          int **l[] = {&g};
+        }
+      int **m = &g;
+      *d = *m = &b;
+    }
+  return 0;
+}