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 PR57103


The following fixes a thinko in move_stmt_op regarding to block
updates.  It also makes the two copies look the same and removes
redundant checking.

Bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2013-04-29  Richard Biener  <rguenther@suse.de>

	PR middle-end/57103
	* tree-cfg.c (move_stmt_op): Fix condition under which to update
	TREE_BLOCK.
	(move_stmt_r): Remove redundant checking.

	* gcc.dg/autopar/pr57103.c: New testcase.

Index: gcc/tree-cfg.c
===================================================================
*** gcc/tree-cfg.c	(revision 198409)
--- gcc/tree-cfg.c	(working copy)
*************** move_stmt_op (tree *tp, int *walk_subtre
*** 6099,6108 ****
  
    if (EXPR_P (t))
      {
!       if (TREE_BLOCK (t) == p->orig_block
  	  || (p->orig_block == NULL_TREE
! 	  && TREE_BLOCK (t) == NULL_TREE))
  	TREE_SET_BLOCK (t, p->new_block);
      }
    else if (DECL_P (t) || TREE_CODE (t) == SSA_NAME)
      {
--- 6099,6117 ----
  
    if (EXPR_P (t))
      {
!       tree block = TREE_BLOCK (t);
!       if (block == p->orig_block
  	  || (p->orig_block == NULL_TREE
! 	      && block != NULL_TREE))
  	TREE_SET_BLOCK (t, p->new_block);
+ #ifdef ENABLE_CHECKING
+       else if (block != NULL_TREE)
+ 	{
+ 	  while (block && TREE_CODE (block) == BLOCK && block != p->orig_block)
+ 	    block = BLOCK_SUPERCONTEXT (block);
+ 	  gcc_assert (block == p->orig_block);
+ 	}
+ #endif
      }
    else if (DECL_P (t) || TREE_CODE (t) == SSA_NAME)
      {
*************** move_stmt_r (gimple_stmt_iterator *gsi_p
*** 6187,6204 ****
    gimple stmt = gsi_stmt (*gsi_p);
    tree block = gimple_block (stmt);
  
!   if (p->orig_block == NULL_TREE
!       || block == p->orig_block
!       || block == NULL_TREE)
      gimple_set_block (stmt, p->new_block);
- #ifdef ENABLE_CHECKING
-   else if (block != p->new_block)
-     {
-       while (block && block != p->orig_block)
- 	block = BLOCK_SUPERCONTEXT (block);
-       gcc_assert (block);
-     }
- #endif
  
    switch (gimple_code (stmt))
      {
--- 6196,6205 ----
    gimple stmt = gsi_stmt (*gsi_p);
    tree block = gimple_block (stmt);
  
!   if (block == p->orig_block
!       || (p->orig_block == NULL_TREE
! 	  && block != NULL_TREE))
      gimple_set_block (stmt, p->new_block);
  
    switch (gimple_code (stmt))
      {
*************** move_block_to_fn (struct function *dest_
*** 6426,6439 ****
  	  e->goto_locus = d->new_block ?
  	      COMBINE_LOCATION_DATA (line_table, e->goto_locus, d->new_block) :
  	      LOCATION_LOCUS (e->goto_locus);
- #ifdef ENABLE_CHECKING
- 	else if (block != d->new_block)
- 	  {
- 	    while (block && block != d->orig_block)
- 	      block = BLOCK_SUPERCONTEXT (block);
- 	    gcc_assert (block);
- 	  }
- #endif
        }
  }
  
--- 6427,6432 ----
Index: gcc/testsuite/gcc.dg/autopar/pr57103.c
===================================================================
*** gcc/testsuite/gcc.dg/autopar/pr57103.c	(revision 0)
--- gcc/testsuite/gcc.dg/autopar/pr57103.c	(working copy)
***************
*** 0 ****
--- 1,19 ----
+ /* { dg-do compile } */
+ /* { dg-options "-O -ftree-parallelize-loops=4" } */
+ 
+ int d[1024];
+ 
+ static inline int foo (void)
+ {
+   int s = 0;
+   int i = 0;
+   for (; i < 1024; i++)
+     s += d[i];
+   return s;
+ }
+ 
+ void bar (void)
+ {
+   if (foo ())
+     __builtin_abort ();
+ }


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