Hi!

compute_all_dependences in 4.7+ can fail, and cond_if_else_store_replacement
isn't prepared to handle the chrec_dont_know DDR added there in case of
failure (with NULL DDR_A/DDR_B).

Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
ok for trunk/4.7?

BTW, tree-ssa-loop-prefetch.c seems to have the same problem, but no idea
how that should be handled in there...

2012-04-30  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/53163
        * tree-ssa-phiopt.c (cond_if_else_store_replacement): Don't ignore
        return value from compute_all_dependences.

        * gcc.c-torture/compile/pr53163.c: New test.

--- gcc/tree-ssa-phiopt.c.jj    2012-04-30 08:06:18.000000000 +0200
+++ gcc/tree-ssa-phiopt.c       2012-04-30 08:59:16.726488101 +0200
@@ -1624,8 +1624,17 @@ cond_if_else_store_replacement (basic_bl
   /* Compute and check data dependencies in both basic blocks.  */
   then_ddrs = VEC_alloc (ddr_p, heap, 1);
   else_ddrs = VEC_alloc (ddr_p, heap, 1);
-  compute_all_dependences (then_datarefs, &then_ddrs, NULL, false);
-  compute_all_dependences (else_datarefs, &else_ddrs, NULL, false);
+  if (!compute_all_dependences (then_datarefs, &then_ddrs, NULL, false)
+      || !compute_all_dependences (else_datarefs, &else_ddrs, NULL, false))
+    {
+      free_dependence_relations (then_ddrs);
+      free_dependence_relations (else_ddrs);
+      free_data_refs (then_datarefs);
+      free_data_refs (else_datarefs);
+      VEC_free (gimple, heap, then_stores);
+      VEC_free (gimple, heap, else_stores);
+      return false;
+    }
   blocks[0] = then_bb;
   blocks[1] = else_bb;
   blocks[2] = join_bb;
--- gcc/testsuite/gcc.c-torture/compile/pr53163.c.jj    2012-04-30 
09:21:40.950512562 +0200
+++ gcc/testsuite/gcc.c-torture/compile/pr53163.c       2012-04-30 
09:21:20.000000000 +0200
@@ -0,0 +1,34 @@
+/* PR tree-optimization/53163 */
+
+struct S { int s; } b, f;
+int a, c;
+
+void
+foo (void)
+{
+  int d, e;
+  for (d = 4; d < 19; ++d)
+    for (e = 2; e >= 0; e--)
+      {
+       a = 0;
+       a = 1;
+      }
+}
+
+void
+bar (void)
+{
+  int g, h, i;
+  for (i = 1; i >= 0; i--)
+    {
+      b = f;
+      for (g = 0; g <= 1; g++)
+       {
+         if (c)
+           break;
+         for (h = 0; h <= 1; h++)
+           foo ();
+         foo ();
+       }
+    }
+}

        Jakub

Reply via email to