The following patch fixes PR70780 uncovered by a mistake I made when
updating the iteration scheme in PRE antic compute.

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

Richard.

2016-04-25  Richard Biener  <rguent...@suse.de>

        PR tree-optimization/70780
        * tree-ssa-pre.c (compute_antic_aux): Also return true if the block
        wasn't visited yet.
        (compute_antic): Mark blocks with abnormal preds as visited as
        they have a final empty antic-in solution already.

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

Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c  (revision 235404)
--- gcc/tree-ssa-pre.c  (working copy)
*************** compute_antic_aux (basic_block block, bo
*** 2081,2086 ****
--- 2081,2087 ----
    unsigned int bii;
    edge e;
    edge_iterator ei;
+   bool was_visited = BB_VISITED (block);
  
    old = ANTIC_OUT = S = NULL;
    BB_VISITED (block) = 1;
*************** compute_antic_aux (basic_block block, bo
*** 2171,2177 ****
  
    clean (ANTIC_IN (block));
  
!   if (!bitmap_set_equal (old, ANTIC_IN (block)))
      changed = true;
  
   maybe_dump_sets:
--- 2172,2178 ----
  
    clean (ANTIC_IN (block));
  
!   if (!was_visited || !bitmap_set_equal (old, ANTIC_IN (block)))
      changed = true;
  
   maybe_dump_sets:
*************** compute_antic (void)
*** 2349,2363 ****
  
    FOR_ALL_BB_FN (block, cfun)
      {
        FOR_EACH_EDGE (e, ei, block->preds)
        if (e->flags & EDGE_ABNORMAL)
          {
            bitmap_set_bit (has_abnormal_preds, block->index);
            break;
          }
  
-       BB_VISITED (block) = 0;
- 
        /* While we are here, give empty ANTIC_IN sets to each block.  */
        ANTIC_IN (block) = bitmap_set_new ();
        PA_IN (block) = bitmap_set_new ();
--- 2350,2367 ----
  
    FOR_ALL_BB_FN (block, cfun)
      {
+       BB_VISITED (block) = 0;
+ 
        FOR_EACH_EDGE (e, ei, block->preds)
        if (e->flags & EDGE_ABNORMAL)
          {
            bitmap_set_bit (has_abnormal_preds, block->index);
+ 
+           /* We also anticipate nothing.  */
+           BB_VISITED (block) = 1;
            break;
          }
  
        /* While we are here, give empty ANTIC_IN sets to each block.  */
        ANTIC_IN (block) = bitmap_set_new ();
        PA_IN (block) = bitmap_set_new ();
Index: gcc/testsuite/gcc.dg/torture/pr70780.c
===================================================================
*** gcc/testsuite/gcc.dg/torture/pr70780.c      (revision 0)
--- gcc/testsuite/gcc.dg/torture/pr70780.c      (working copy)
***************
*** 0 ****
--- 1,26 ----
+ /* { dg-do run } */
+ 
+ int a, b, c, *d, e;
+ 
+ static int
+ fn1 () 
+ {
+   if (a)
+     goto l1;
+ l2: while (b)
+       if (*d)
+       return c;
+     for (e = 0; e; e++)
+       {
+       goto l2;
+ l1:;
+       }
+     return 0; 
+ }
+ 
+ int
+ main ()
+ {
+   fn1 ();
+   return 0; 
+ }

Reply via email to