[ tree-ssa] PRE problem

Daniel Berlin dberlin@dberlin.org
Fri Feb 20 23:56:00 GMT 2004


> Dunno.  Dan?
>

You actually don't want to do what you are doing unless you actually 
need to perform an insertion. The verification procedure should not be 
updating those annotations, because we might not actually make that 
insertion, in which case, you've just screwed up the annotation.

As for signaling to the caller that nothing should be done, that is 
simple.
Simply leave the value alone, and do nothing. It's just another case of 
the e-ssa versions not matching.

Thus, what you want is this, if anything (i'm testing it now), with 
whatever propagate_value change you'd like to make :P:
Index: tree-ssa-pre.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/Attic/tree-ssa-pre.c,v
retrieving revision 1.1.4.129
diff -u -3 -p -r1.1.4.129 tree-ssa-pre.c
--- tree-ssa-pre.c	30 Jan 2004 13:14:18 -0000	1.1.4.129
+++ tree-ssa-pre.c	20 Feb 2004 23:40:31 -0000
@@ -141,9 +141,10 @@ static inline tree find_rhs_use_for_var
  static tree create_ephi_node (basic_block, unsigned int);
  static inline int opnum_of_phi (tree, int);
  static inline int opnum_of_ephi (const tree, const edge);
-static tree subst_phis (struct expr_info *, tree, basic_block, 
basic_block);
-static void generate_expr_as_of_bb (tree, basic_block, basic_block);
-static void generate_vops_as_of_bb (tree, basic_block, basic_block);
+static tree subst_phis (struct expr_info *, tree, basic_block, 
basic_block,
+			bool);
+static void generate_expr_as_of_bb (tree, basic_block, basic_block, 
bool);
+static void generate_vops_as_of_bb (tree, basic_block, basic_block, 
bool);
  static void rename_1 (struct expr_info *);
  static void process_delayed_rename (struct expr_info *, tree, tree);
  static void assign_new_class (tree, varray_type *, varray_type *);
@@ -1205,7 +1206,8 @@ opnum_of_phi (tree phi, int j)
     block BB.  */

  static void
-generate_expr_as_of_bb (tree expr, basic_block pred, basic_block bb)
+generate_expr_as_of_bb (tree expr, basic_block pred, basic_block bb,
+			bool for_insert)
  {
    use_optype uses = STMT_USE_OPS (expr);
    bool replaced_constants = false;
@@ -1223,10 +1225,16 @@ generate_expr_as_of_bb (tree expr, basic
  	    {
  	      int opnum = opnum_of_phi (phi, pred->index);
  	      tree p = PHI_ARG_DEF (phi, opnum);
-	      *vp = p;
-	      if (!phi_ssa_name_p (p))
-		replaced_constants = true;
-	      break;
+	      if (may_propagate_copy (*vp, p))
+		{
+		  if (for_insert)
+		    propagate_copy (vp, p);
+		  else
+		    *vp = p;
+		  if (!phi_ssa_name_p (p))
+		    replaced_constants = true;
+		  break;
+		}
  	    }
  	}
      }
@@ -1242,7 +1250,8 @@ generate_expr_as_of_bb (tree expr, basic
     ops for the bb.  */

  static void
-generate_vops_as_of_bb (tree expr, basic_block pred, basic_block bb)
+generate_vops_as_of_bb (tree expr, basic_block pred, basic_block bb,
+			bool for_insert)
  {
    vuse_optype vuses = STMT_VUSE_OPS (expr);
    size_t i;
@@ -1258,8 +1267,14 @@ generate_vops_as_of_bb (tree expr, basic
  	    {
  	      int opnum = opnum_of_phi (phi, pred->index);
  	      tree p = PHI_ARG_DEF (phi, opnum);
-	      *VUSE_OP_PTR (vuses, i) = p;
-	      break;
+	      if (may_propagate_copy (*VUSE_OP_PTR (vuses, i), p))
+		{
+		  if (for_insert)
+		    propagate_copy (VUSE_OP_PTR (vuses, i), p);
+		  else
+		    *VUSE_OP_PTR (vuses, i) = p;
+		  break;
+		}
  	    }
  	}
      }
@@ -1269,7 +1284,8 @@ generate_vops_as_of_bb (tree expr, basic
     in BB. */

  static tree
-subst_phis (struct expr_info *ei, tree Z, basic_block pred, 
basic_block bb)
+subst_phis (struct expr_info *ei, tree Z, basic_block pred, 
basic_block bb,
+	    bool for_insert)
  {
    tree stmt_copy;
    size_t i;
@@ -1285,7 +1301,7 @@ subst_phis (struct expr_info *ei, tree Z
    create_stmt_ann (stmt_copy);
    modify_stmt (stmt_copy);
    get_stmt_operands (stmt_copy);
-  generate_expr_as_of_bb (stmt_copy, pred, bb);
+  generate_expr_as_of_bb (stmt_copy, pred, bb, for_insert);
    set_bb_for_stmt (stmt_copy, bb);
    modify_stmt (stmt_copy);
    get_stmt_operands (stmt_copy);
@@ -1305,7 +1321,7 @@ subst_phis (struct expr_info *ei, tree Z
          add_vuse (VUSE_OP (vuses, i), stmt_copy);
        finalize_ssa_stmt_operands (stmt_copy);

-      generate_vops_as_of_bb (stmt_copy, pred, bb);
+      generate_vops_as_of_bb (stmt_copy, pred, bb, for_insert);
      }
    else
      {
@@ -1517,8 +1533,8 @@ process_delayed_rename (struct expr_info
  	  EPHI_ARG_DELAYED_RENAME (exp_phi, opnd_num) = false;
  	  def = opnd;
  	  newexp = subst_phis (ei, real_occ,
-			      EPHI_ARG_EDGE (exp_phi, opnd_num)->src,
-			      bb_for_stmt (exp_phi));
+			       EPHI_ARG_EDGE (exp_phi, opnd_num)->src,
+			       bb_for_stmt (exp_phi), false);

  	  /* For operands defined by EPHIs, we need to compare the
  	     generated expression and the phi result.
@@ -2095,7 +2111,7 @@ insert_one_operand (struct expr_info *ei
    copy = unshare_expr (copy);
    expr = build (MODIFY_EXPR, TREE_TYPE (ei->expr),
  		temp, copy);
-  expr = subst_phis (ei, expr, bb, bb_for_stmt (ephi));
+  expr = subst_phis (ei, expr, bb, bb_for_stmt (ephi), true);
    newtemp = make_ssa_name (temp, expr);
    TREE_OPERAND (expr, 0) = newtemp;
    copy = TREE_OPERAND (expr, 1);



More information about the Gcc mailing list