OSDN Git Service

2005-07-07 Feng Wang <fengwang@nudt.edu.cn>
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-pre.c
index 183b2cd..eab18d3 100644 (file)
@@ -17,14 +17,13 @@ GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with GCC; see the file COPYING.  If not, write to
-the Free Software Foundation, 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
+the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+Boston, MA 02110-1301, USA.  */
 
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
 #include "tm.h"
-#include "errors.h"
 #include "ggc.h"
 #include "tree.h"
 #include "basic-block.h"
@@ -178,6 +177,8 @@ Boston, MA 02111-1307, USA.  */
    useful only for debugging, since we don't do identity lookups.  */
 
 
+static bool in_fre = false;
+
 /* A value set element.  Basically a single linked list of
    expressions/values.  */
 typedef struct value_set_node
@@ -1467,7 +1468,8 @@ find_or_generate_expression (basic_block block, tree expr, tree stmts)
       gcc_assert (UNARY_CLASS_P (genop)
                  || BINARY_CLASS_P (genop)
                  || COMPARISON_CLASS_P (genop)
-                 || REFERENCE_CLASS_P (genop));
+                 || REFERENCE_CLASS_P (genop)
+                 || TREE_CODE (genop) == CALL_EXPR);
       genop = create_expression_by_pieces (block, genop, stmts);
     }
   return genop;
@@ -1526,8 +1528,8 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts)
 
        if (op2)          
          genop2 = find_or_generate_expression (block, op2, stmts);
-       folded = fold (build (TREE_CODE (expr), TREE_TYPE (expr),
-                             genop0, genarglist, genop2));
+       folded = fold_build3 (TREE_CODE (expr), TREE_TYPE (expr),
+                             genop0, genarglist, genop2);
        break;
        
        
@@ -1541,8 +1543,8 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts)
        tree op2 = TREE_OPERAND (expr, 1);
        tree genop1 = find_or_generate_expression (block, op1, stmts);
        tree genop2 = find_or_generate_expression (block, op2, stmts);
-       folded = fold (build (TREE_CODE (expr), TREE_TYPE (expr), 
-                             genop1, genop2));
+       folded = fold_build2 (TREE_CODE (expr), TREE_TYPE (expr), 
+                             genop1, genop2);
        break;
       }
 
@@ -1550,8 +1552,8 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts)
       {
        tree op1 = TREE_OPERAND (expr, 0);
        tree genop1 = find_or_generate_expression (block, op1, stmts);
-       folded = fold (build (TREE_CODE (expr), TREE_TYPE (expr), 
-                             genop1));
+       folded = fold_build1 (TREE_CODE (expr), TREE_TYPE (expr), 
+                             genop1);
        break;
       }
 
@@ -1591,6 +1593,8 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts)
      that we will return.  */
   temp = create_tmp_var (TREE_TYPE (expr), "pretmp");
   add_referenced_tmp_var (temp);
+  if (TREE_CODE (TREE_TYPE (expr)) == COMPLEX_TYPE)
+    DECL_COMPLEX_GIMPLE_REG_P (temp) = 1;
   newexpr = build (MODIFY_EXPR, TREE_TYPE (expr), temp, newexpr);
   name = make_ssa_name (temp, newexpr);
   TREE_OPERAND (newexpr, 0) = name;
@@ -1697,6 +1701,8 @@ insert_into_preds_of_block (basic_block block, value_set_node_t node,
   /* Now build a phi for the new variable.  */
   temp = create_tmp_var (type, tmpname);
   add_referenced_tmp_var (temp);
+  if (TREE_CODE (type) == COMPLEX_TYPE)
+    DECL_COMPLEX_GIMPLE_REG_P (temp) = 1;
   temp = create_phi_node (temp, block);
   NECESSARY (temp) = 0; 
   VEC_safe_push (tree, heap, inserted_exprs, temp);
@@ -2029,17 +2035,32 @@ create_value_expr_from (tree expr, basic_block block, tree stmt)
 
   if (code == TREE_LIST)
     {
+      tree op = NULL_TREE;
       tree temp = NULL_TREE;
       if (TREE_CHAIN (vexpr))
        temp = create_value_expr_from (TREE_CHAIN (vexpr), block, stmt);      
       TREE_CHAIN (vexpr) = temp ? temp : TREE_CHAIN (vexpr);
       
+
+      /* Recursively value-numberize reference ops.  */
+      if (REFERENCE_CLASS_P (TREE_VALUE (vexpr)))
+       {
+         tree tempop;
+         op = TREE_VALUE (vexpr);
+         tempop = create_value_expr_from (op, block, stmt);
+         op = tempop ? tempop : op;
+         
+         TREE_VALUE (vexpr)  = vn_lookup_or_add (op, stmt);
+       }
+      else
+       {
+         op = TREE_VALUE (vexpr);
+         TREE_VALUE (vexpr) = vn_lookup_or_add (TREE_VALUE (vexpr), NULL);
+       }
       /* This is the equivalent of inserting op into EXP_GEN like we
         do below */
-      if (!is_undefined_value (TREE_VALUE (vexpr)))
-       value_insert_into_set (EXP_GEN (block), TREE_VALUE (vexpr));      
-         
-      TREE_VALUE (vexpr) = vn_lookup_or_add (TREE_VALUE (vexpr), NULL);
+      if (!is_undefined_value (op))
+       value_insert_into_set (EXP_GEN (block), op);
 
       return vexpr;
     }
@@ -2107,8 +2128,8 @@ can_value_number_call (tree stmt)
   tree call = get_call_expr_in (stmt);
 
   /* This is a temporary restriction until we translate vuses through
-     phi nodes.  */
-  if (!ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS))
+     phi nodes.  This is only needed for PRE, of course.  */
+  if (!in_fre && !ZERO_SSA_OPERANDS (stmt, SSA_OP_ALL_VIRTUALS))
     return false;  
   if (call_expr_flags (call)  & (ECF_PURE | ECF_CONST))
     return true;
@@ -2321,7 +2342,7 @@ eliminate (void)
 
                  /* If we removed EH side effects from the statement, clean
                     its EH information.  */
-                 if (maybe_clean_eh_stmt (stmt))
+                 if (maybe_clean_or_replace_eh_stmt (stmt, stmt))
                    {
                      bitmap_set_bit (need_eh_cleanup,
                                      bb_for_stmt (stmt)->index);
@@ -2453,6 +2474,8 @@ static void
 init_pre (bool do_fre)
 {
   basic_block bb;
+  
+  in_fre = do_fre;
 
   inserted_exprs = NULL;
   vn_init ();