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 PR44784


With enabling SCCVN insertion also during PRE we have to fix the
dominance check in bitmap_find_leader for new stmts we get during
insertions.  The following does so in a minimal way.

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

Richard.

2010-07-05  Richard Guenther  <rguenther@suse.de>

	PR tree-optimization/44784
	* tree-ssa-pre.c (bitmap_find_leader): Fix dominance check
	for inserted stmts.
	(find_or_generate_expression): Fix SCCVN insertion check.

	* gcc.c-torture/compile/pr44784.c: New testcase.

Index: gcc/tree-ssa-pre.c
===================================================================
*** gcc/tree-ssa-pre.c	(revision 161820)
--- gcc/tree-ssa-pre.c	(working copy)
*************** bitmap_find_leader (bitmap_set_t set, un
*** 1955,1961 ****
  	      gimple def_stmt = SSA_NAME_DEF_STMT (PRE_EXPR_NAME (val));
  	      if (gimple_code (def_stmt) != GIMPLE_PHI
  		  && gimple_bb (def_stmt) == gimple_bb (stmt)
! 		  && gimple_uid (def_stmt) >= gimple_uid (stmt))
  		continue;
  	    }
  	  return val;
--- 1955,1964 ----
  	      gimple def_stmt = SSA_NAME_DEF_STMT (PRE_EXPR_NAME (val));
  	      if (gimple_code (def_stmt) != GIMPLE_PHI
  		  && gimple_bb (def_stmt) == gimple_bb (stmt)
! 		  /* PRE insertions are at the end of the basic-block
! 		     and have UID 0.  */
! 		  && (gimple_uid (def_stmt) == 0
! 		      || gimple_uid (def_stmt) >= gimple_uid (stmt)))
  		continue;
  	    }
  	  return val;
*************** find_or_generate_expression (basic_block
*** 3021,3029 ****
      }
  
    /* If it's still NULL, it must be a complex expression, so generate
!      it recursively.  Not so for FRE though.  */
    if (genop == NULL
!       && !in_fre)
      {
        bitmap_set_t exprset;
        unsigned int lookfor = get_expr_value_id (expr);
--- 3024,3033 ----
      }
  
    /* If it's still NULL, it must be a complex expression, so generate
!      it recursively.  Not so if inserting expressions for values generated
!      by SCCVN.  */
    if (genop == NULL
!       && !domstmt)
      {
        bitmap_set_t exprset;
        unsigned int lookfor = get_expr_value_id (expr);
Index: gcc/testsuite/gcc.c-torture/compile/pr44784.c
===================================================================
*** gcc/testsuite/gcc.c-torture/compile/pr44784.c	(revision 0)
--- gcc/testsuite/gcc.c-torture/compile/pr44784.c	(revision 0)
***************
*** 0 ****
--- 1,47 ----
+ typedef struct rtx_def *rtx;
+ enum rtx_code { SUBREG };
+ typedef union rtunion_def {
+     long rtint;
+     unsigned long rtuint;
+     rtx rtx;
+ } rtunion;
+ struct rtx_def {
+     enum rtx_code code: 8;
+     rtunion fld[1];
+ };
+ typedef struct simple_bitmap_def {
+     unsigned long long elms[1];
+ } *sbitmap;
+ struct df_link {
+     struct df_link *next;
+     rtx reg;
+ };
+ typedef enum { UNDEFINED,   CONSTANT,   VARYING } latticevalue;
+ typedef struct {
+     latticevalue lattice_val;
+ } value;
+ static value *values;
+ static sbitmap ssa_edges;
+ void defs_to_varying (struct df_link *start)
+ {
+   struct df_link *currdef;
+   for (currdef = start;
+        currdef;
+        currdef = currdef->next)
+     {
+       rtx reg = currdef->reg;
+       if (values[(reg->code == SUBREG
+ 		  ? reg->fld[0].rtx
+ 		  : reg)->fld[0].rtuint].lattice_val != VARYING)
+ 	ssa_edges->elms [(reg->code == SUBREG
+ 			  ? reg->fld[0].rtx
+ 			  : reg)->fld[0].rtuint / 64]
+ 	    |= ((unsigned long long) 1
+ 		<< (reg->code == SUBREG
+ 		    ? reg->fld[0].rtx
+ 		    : reg)->fld[0].rtuint % 64);
+       values[(reg->code == SUBREG
+ 	      ? reg->fld[0].rtx
+ 	      : reg)->fld[0].rtuint].lattice_val = VARYING;
+     }
+ }


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