This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR76783


This patch fixes PR76783 by not just using any PRE order but RPO order
for the SSA propagator.  This makes sure to visit PHI args from
non-backedges before the PHI node itself.

It also fixes the assumption that BB_VISITED is well-defined on
pass entry (but still keeps clearing it at the end because not
doing so ICEs IRA later which assumes that BB_VISITED is cleared)

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

Richard.

2016-08-16  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/76783
	* tree-ssa-propagate.c (ssa_prop_init): Use RPO order.  Clear
	BB visited flags at start.

	* gcc.dg/pr76783.c: New testcase.

Index: gcc/tree-ssa-propagate.c
===================================================================
*** gcc/tree-ssa-propagate.c	(revision 239473)
--- gcc/tree-ssa-propagate.c	(working copy)
*************** ssa_prop_init (void)
*** 422,429 ****
    /* Worklist of basic-blocks.  */
    bb_to_cfg_order = XNEWVEC (int, last_basic_block_for_fn (cfun) + 1);
    cfg_order_to_bb = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
!   int n = pre_and_rev_post_order_compute_fn (cfun, cfg_order_to_bb,
! 					     NULL, false);
    for (int i = 0; i < n; ++i)
      bb_to_cfg_order[cfg_order_to_bb[i]] = i;
    cfg_blocks = BITMAP_ALLOC (NULL);
--- 422,429 ----
    /* Worklist of basic-blocks.  */
    bb_to_cfg_order = XNEWVEC (int, last_basic_block_for_fn (cfun) + 1);
    cfg_order_to_bb = XNEWVEC (int, n_basic_blocks_for_fn (cfun));
!   int n = pre_and_rev_post_order_compute_fn (cfun, NULL,
! 					     cfg_order_to_bb, false);
    for (int i = 0; i < n; ++i)
      bb_to_cfg_order[cfg_order_to_bb[i]] = i;
    cfg_blocks = BITMAP_ALLOC (NULL);
*************** ssa_prop_init (void)
*** 453,459 ****
  	  gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun));
  	}
  
!       gcc_assert (! (bb->flags & BB_VISITED));
        FOR_EACH_EDGE (e, ei, bb->succs)
  	e->flags &= ~EDGE_EXECUTABLE;
      }
--- 453,459 ----
  	  gimple_set_uid (stmt, inc_gimple_stmt_max_uid (cfun));
  	}
  
!       bb->flags &= ~BB_VISITED;
        FOR_EACH_EDGE (e, ei, bb->succs)
  	e->flags &= ~EDGE_EXECUTABLE;
      }
Index: gcc/testsuite/gcc.dg/pr76783.c
===================================================================
*** gcc/testsuite/gcc.dg/pr76783.c	(revision 0)
--- gcc/testsuite/gcc.dg/pr76783.c	(working copy)
***************
*** 0 ****
--- 1,28 ----
+ /* { dg-do run } */
+ /* { dg-require-effective-target int128 } */
+ /* { dg-options "-Og -w -Wno-psabi" } */
+ 
+ typedef unsigned __int128 u128;
+ typedef unsigned __int128 v64u128 __attribute__ ((vector_size (64)));
+ 
+ u128 __attribute__ ((noinline, noclone))
+ foo (unsigned c, v64u128 v)
+ {
+   v64u128 u;
+   if (c) {
+     u = (v64u128){(u128)0, (u128)0};
+   } else {
+     u = (v64u128){(u128)0, (u128)1};
+   }
+   u += v;
+   return u[1];
+ }
+ 
+ int
+ main ()
+ {
+   u128 x = foo (0, (v64u128){ });
+   if (x != 1)
+     __builtin_abort();
+   return 0;
+ }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]