2005-04-14 Daniel Berlin <dberlin@dberlin.org>
authordberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Apr 2005 15:39:19 +0000 (15:39 +0000)
committerdberlin <dberlin@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 15 Apr 2005 15:39:19 +0000 (15:39 +0000)
* tree-ssa-pre.c (compute_avail): It's okay to have
TREE_INVARIANT's here, and value number the resulting expressions.
(create_expression_by_pieces): Make sure operands that were
min_invariant when we started, stay that way.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@98187 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/tree-ssa-pre.c

index d2635af..3a9a6eb 100644 (file)
@@ -1,3 +1,10 @@
+2005-04-14  Daniel Berlin <dberlin@dberlin.org>
+
+       * tree-ssa-pre.c (compute_avail): It's okay to have
+       TREE_INVARIANT's here, and value number the resulting expressions.
+       (create_expression_by_pieces): Make sure operands that were 
+       min_invariant when we started, stay that way.
+       
 2005-04-15  David Edelsohn  <edelsohn@gnu.org>
 
        * doc/install.texi (*-ibm-aix*): Add comment about system limits.
index cecc97e..2e2788e 100644 (file)
@@ -950,6 +950,10 @@ phi_translate (tree expr, value_set_t set, basic_block pred,
     }
 }
 
+/* For each expression in SET, translate the value handles through phi nodes
+   in PHIBLOCK using edge PHIBLOCK->PRED, and store the resulting
+   expressions in DEST.  */
+
 static void
 phi_translate_set (value_set_t dest, value_set_t set, basic_block pred,
                   basic_block phiblock)
@@ -1370,7 +1374,7 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts)
     case tcc_unary:
       {
        tree_stmt_iterator tsi;
-       tree forced_stmts;
+       tree forced_stmts = NULL;
        tree genop1;
        tree temp;
        tree folded;
@@ -1380,7 +1384,14 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts)
        add_referenced_tmp_var (temp);
        folded = fold (build (TREE_CODE (expr), TREE_TYPE (expr), 
                              genop1));
-       newexpr = force_gimple_operand (folded, &forced_stmts, false, NULL);
+       /* If the generated operand  is already GIMPLE min_invariant
+          just use it instead of calling force_gimple_operand on it,
+          since that may make it not invariant by copying it into an
+          assignment.  */
+       if (!is_gimple_min_invariant (genop1))
+         newexpr = force_gimple_operand (folded, &forced_stmts, false, NULL);
+       else
+         newexpr = genop1;
        if (forced_stmts)
          {
            tsi = tsi_start (forced_stmts);
@@ -1963,11 +1974,10 @@ compute_avail (void)
              vuse_optype vuses = STMT_VUSE_OPS (stmt);
 
              STRIP_USELESS_TYPE_CONVERSION (rhs);
-             if ((UNARY_CLASS_P (rhs)
+             if (UNARY_CLASS_P (rhs)
                  || BINARY_CLASS_P (rhs)
                  || COMPARISON_CLASS_P (rhs)
                  || REFERENCE_CLASS_P (rhs))
-                 && !TREE_INVARIANT (rhs))
                {
                  /* For binary, unary, and reference expressions,
                     create a duplicate expression with the operands
@@ -1985,6 +1995,7 @@ compute_avail (void)
              else if (TREE_CODE (rhs) == SSA_NAME
                       || is_gimple_min_invariant (rhs)
                       || TREE_CODE (rhs) == ADDR_EXPR
+                      || TREE_INVARIANT (rhs)
                       || DECL_P (rhs))
                {
                  /* Compute a value number for the RHS of the statement