re PR tree-optimization/61438 (ICE on valid code at -O3 on x86_64-linux-gnu in in...
authorRichard Biener <rguenther@suse.de>
Tue, 10 Jun 2014 14:18:50 +0000 (14:18 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Tue, 10 Jun 2014 14:18:50 +0000 (14:18 +0000)
2014-06-10  Richard Biener  <rguenther@suse.de>

PR tree-optimization/61438
* tree-ssa-pre.c (eliminate_dom_walker): Add do_pre member.
(eliminate_dom_walker::before_dom_children): Only try to inhibit
insertion of IVs if running PRE.
(eliminate): Adjust.
(pass_pre::execute): Likewise.
(pass_fre::execute): Likewise.

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

From-SVN: r211413

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr61438.c [new file with mode: 0644]
gcc/tree-ssa-pre.c

index 7d37ddb..180d1c8 100644 (file)
@@ -1,5 +1,15 @@
 2014-06-10  Richard Biener  <rguenther@suse.de>
 
+       PR tree-optimization/61438
+       * tree-ssa-pre.c (eliminate_dom_walker): Add do_pre member.
+       (eliminate_dom_walker::before_dom_children): Only try to inhibit
+       insertion of IVs if running PRE.
+       (eliminate): Adjust.
+       (pass_pre::execute): Likewise.
+       (pass_fre::execute): Likewise.
+
+2014-06-10  Richard Biener  <rguenther@suse.de>
+
        PR middle-end/61456
        * tree-ssa-alias.c (nonoverlapping_component_refs_of_decl_p):
        Do not use the main variant for the type comparison.
index f3f1162..53b6134 100644 (file)
@@ -1,5 +1,10 @@
 2014-06-10  Richard Biener  <rguenther@suse.de>
 
+       PR tree-optimization/61438
+       * gcc.dg/torture/pr61438.c: New testcase.
+
+2014-06-10  Richard Biener  <rguenther@suse.de>
+
        PR middle-end/61456
        * g++.dg/opt/pr61456.C: New testcase.
 
diff --git a/gcc/testsuite/gcc.dg/torture/pr61438.c b/gcc/testsuite/gcc.dg/torture/pr61438.c
new file mode 100644 (file)
index 0000000..2381999
--- /dev/null
@@ -0,0 +1,48 @@
+/* { dg-do run } */
+
+extern void abort (void);
+
+int a, c, **d, e, g;
+static int b = 1;
+
+struct
+{
+  int f0;
+} f;
+
+void
+foo ()
+{
+  int h, *i = &a;
+  for (; e;)
+    {
+      for (c = 0; c < 1; c++)
+       for (; b;)
+         ;
+      for (;;)
+       {
+         if (a)
+           {
+             for (; f.f0; f.f0++)
+               ;
+             if (g)
+               break;
+           }
+         for (h = 0; h < 2; h++)
+           {
+             i = *d;
+             if (!i)
+               abort ();
+           }
+       }
+    }
+  if (!i)
+    abort ();
+}
+
+int
+main ()
+{
+  foo (); 
+  return 0;
+}
index f497f90..89e94e9 100644 (file)
@@ -3992,10 +3992,13 @@ eliminate_insert (gimple_stmt_iterator *gsi, tree val)
 class eliminate_dom_walker : public dom_walker
 {
 public:
-  eliminate_dom_walker (cdi_direction direction) : dom_walker (direction) {}
+  eliminate_dom_walker (cdi_direction direction, bool do_pre_)
+      : dom_walker (direction), do_pre (do_pre_) {}
 
   virtual void before_dom_children (basic_block);
   virtual void after_dom_children (basic_block);
+
+  bool do_pre;
 };
 
 /* Perform elimination for the basic-block B during the domwalk.  */
@@ -4192,7 +4195,8 @@ eliminate_dom_walker::before_dom_children (basic_block b)
                 variable.  In other cases the vectorizer won't do anything
                 anyway (either it's loop invariant or a complicated
                 expression).  */
-             if (flag_tree_loop_vectorize
+             if (do_pre
+                 && flag_tree_loop_vectorize
                  && gimple_assign_single_p (stmt)
                  && TREE_CODE (sprime) == SSA_NAME
                  && loop_outer (b->loop_father))
@@ -4434,7 +4438,7 @@ eliminate_dom_walker::after_dom_children (basic_block)
 /* Eliminate fully redundant computations.  */
 
 static unsigned int
-eliminate (void)
+eliminate (bool do_pre)
 {
   gimple_stmt_iterator gsi;
   gimple stmt;
@@ -4448,7 +4452,8 @@ eliminate (void)
   el_avail.create (0);
   el_avail_stack.create (0);
 
-  eliminate_dom_walker (CDI_DOMINATORS).walk (cfun->cfg->x_entry_block_ptr);
+  eliminate_dom_walker (CDI_DOMINATORS,
+                       do_pre).walk (cfun->cfg->x_entry_block_ptr);
 
   el_avail.release ();
   el_avail_stack.release ();
@@ -4779,7 +4784,7 @@ pass_pre::execute (function *fun)
   gsi_commit_edge_inserts ();
 
   /* Remove all the redundant expressions.  */
-  todo |= eliminate ();
+  todo |= eliminate (true);
 
   statistics_counter_event (fun, "Insertions", pre_stats.insertions);
   statistics_counter_event (fun, "PA inserted", pre_stats.pa_insert);
@@ -4864,7 +4869,7 @@ pass_fre::execute (function *fun)
   memset (&pre_stats, 0, sizeof (pre_stats));
 
   /* Remove all the redundant expressions.  */
-  todo |= eliminate ();
+  todo |= eliminate (false);
 
   todo |= fini_eliminate ();