Patchwork Fix PR53070

login
register
mail settings
Submitter Richard Guenther
Date April 23, 2012, 11:48 a.m.
Message ID <Pine.LNX.4.64.1204231347520.23071@jbgna.fhfr.qr>
Download mbox | patch
Permalink /patch/154395/
State New
Headers show

Comments

Richard Guenther - April 23, 2012, 11:48 a.m.
if-conversion fails to free a basic-block predicates (notably that
of the latch).

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2012-04-23  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/53070
	* tree-if-conv.c (combine_blocks): Free predicates in all blocks.
	(main_tree_if_conversion): Verify we succeeded in that.

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

Patch

Index: gcc/tree-if-conv.c
===================================================================
--- gcc/tree-if-conv.c	(revision 186695)
+++ gcc/tree-if-conv.c	(working copy)
@@ -1651,8 +1651,8 @@  combine_blocks (struct loop *loop)
       free_bb_predicate (bb);
       if (bb_with_exit_edge_p (loop, bb))
 	{
+	  gcc_assert (exit_bb == NULL);
 	  exit_bb = bb;
-	  break;
 	}
     }
   gcc_assert (exit_bb != loop->latch);
@@ -1779,6 +1779,7 @@  main_tree_if_conversion (void)
   struct loop *loop;
   bool changed = false;
   unsigned todo = 0;
+  basic_block bb;
 
   if (number_of_loops () <= 1)
     return 0;
@@ -1794,6 +1795,11 @@  main_tree_if_conversion (void)
 
   free_dominance_info (CDI_POST_DOMINATORS);
 
+#ifdef ENABLE_CHECKING
+  FOR_EACH_BB (bb)
+    gcc_assert (!bb->aux);
+#endif
+
   return todo;
 }
 
Index: gcc/testsuite/gcc.dg/torture/pr53070.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr53070.c	(revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr53070.c	(revision 0)
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+/* { dg-options "-ffast-math -ftree-loop-if-convert -fno-tree-loop-im" } */
+int
+foo (int c)
+{
+  int t = 0, i = 0;
+  for (; i < 100; i++)
+    t += c ? c : 1;
+  return t;
+}