OSDN Git Service

* config/spu/spu.c (cpat_info): Fix an incorrectly identified case.
[pf3gnuchains/gcc-fork.git] / gcc / tree-ssa-math-opts.c
index 825c0bd..5b28340 100644 (file)
@@ -111,7 +111,7 @@ struct occurrence {
      inserted in BB.  */
   tree recip_def;
 
-  /* If non-NULL, the MODIFY_EXPR for a reciprocal computation that
+  /* If non-NULL, the GIMPLE_MODIFY_STMT for a reciprocal computation that
      was inserted in BB.  */
   tree recip_def_stmt;
 
@@ -274,9 +274,9 @@ compute_merit (struct occurrence *occ)
 static inline bool
 is_division_by (tree use_stmt, tree def)
 {
-  return TREE_CODE (use_stmt) == MODIFY_EXPR
-        && TREE_CODE (TREE_OPERAND (use_stmt, 1)) == RDIV_EXPR
-        && TREE_OPERAND (TREE_OPERAND (use_stmt, 1), 1) == def;
+  return TREE_CODE (use_stmt) == GIMPLE_MODIFY_STMT
+        && TREE_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1)) == RDIV_EXPR
+        && TREE_OPERAND (GIMPLE_STMT_OPERAND (use_stmt, 1), 1) == def;
 }
 
 /* Walk the subset of the dominator tree rooted at OCC, setting the
@@ -303,9 +303,9 @@ insert_reciprocals (block_stmt_iterator *def_bsi, struct occurrence *occ,
       /* Make a variable with the replacement and substitute it.  */
       type = TREE_TYPE (def);
       recip_def = make_rename_temp (type, "reciptmp");
-      new_stmt = build2 (MODIFY_EXPR, void_type_node, recip_def,
-                        fold_build2 (RDIV_EXPR, type,
-                                     build_real (type, dconst1), def));
+      new_stmt = build2 (GIMPLE_MODIFY_STMT, void_type_node, recip_def,
+                        fold_build2 (RDIV_EXPR, type, build_one_cst (type),
+                                     def));
   
   
       if (occ->bb_has_division)
@@ -353,7 +353,7 @@ replace_reciprocal (use_operand_p use_p)
 
   if (occ->recip_def && use_stmt != occ->recip_def_stmt)
     {
-      TREE_SET_CODE (TREE_OPERAND (use_stmt, 1), MULT_EXPR);
+      TREE_SET_CODE (GIMPLE_STMT_OPERAND (use_stmt, 1), MULT_EXPR);
       SET_USE (use_p, occ->recip_def);
       fold_stmt_inplace (use_stmt);
       update_stmt (use_stmt);
@@ -417,17 +417,20 @@ execute_cse_reciprocals_1 (block_stmt_iterator *def_bsi, tree def)
   threshold = targetm.min_divisions_for_recip_mul (TYPE_MODE (TREE_TYPE (def)));
   if (count >= threshold)
     {
+      tree use_stmt;
       for (occ = occ_head; occ; occ = occ->next)
        {
          compute_merit (occ);
          insert_reciprocals (def_bsi, occ, def, NULL, threshold);
        }
 
-      FOR_EACH_IMM_USE_SAFE (use_p, use_iter, def)
+      FOR_EACH_IMM_USE_STMT (use_stmt, use_iter, def)
        {
-         tree use_stmt = USE_STMT (use_p);
          if (is_division_by (use_stmt, def))
-           replace_reciprocal (use_p);
+           {
+             FOR_EACH_IMM_USE_ON_STMT (use_p, use_iter)
+               replace_reciprocal (use_p);
+           }
        }
     }
 
@@ -447,7 +450,7 @@ gate_cse_reciprocals (void)
 
 /* Go through all the floating-point SSA_NAMEs, and call
    execute_cse_reciprocals_1 on each of them.  */
-static void
+static unsigned int
 execute_cse_reciprocals (void)
 {
   basic_block bb;
@@ -457,7 +460,8 @@ execute_cse_reciprocals (void)
                                sizeof (struct occurrence),
                                n_basic_blocks / 3 + 1);
 
-  calculate_dominance_info (CDI_DOMINATORS | CDI_POST_DOMINATORS);
+  calculate_dominance_info (CDI_DOMINATORS);
+  calculate_dominance_info (CDI_POST_DOMINATORS);
 
 #ifdef ENABLE_CHECKING
   FOR_EACH_BB (bb)
@@ -465,10 +469,10 @@ execute_cse_reciprocals (void)
 #endif
 
   for (arg = DECL_ARGUMENTS (cfun->decl); arg; arg = TREE_CHAIN (arg))
-    if (default_def (arg)
+    if (gimple_default_def (cfun, arg)
        && FLOAT_TYPE_P (TREE_TYPE (arg))
        && is_gimple_reg (arg))
-      execute_cse_reciprocals_1 (NULL, default_def (arg));
+      execute_cse_reciprocals_1 (NULL, gimple_default_def (cfun, arg));
 
   FOR_EACH_BB (bb)
     {
@@ -486,7 +490,7 @@ execute_cse_reciprocals (void)
       for (bsi = bsi_after_labels (bb); !bsi_end_p (bsi); bsi_next (&bsi))
         {
          tree stmt = bsi_stmt (bsi);
-         if (TREE_CODE (stmt) == MODIFY_EXPR
+         if (TREE_CODE (stmt) == GIMPLE_MODIFY_STMT
              && (def = SINGLE_SSA_TREE_OPERAND (stmt, SSA_OP_DEF)) != NULL
              && FLOAT_TYPE_P (TREE_TYPE (def))
              && TREE_CODE (def) == SSA_NAME)
@@ -494,8 +498,10 @@ execute_cse_reciprocals (void)
        }
     }
 
-  free_dominance_info (CDI_DOMINATORS | CDI_POST_DOMINATORS);
+  free_dominance_info (CDI_DOMINATORS);
+  free_dominance_info (CDI_POST_DOMINATORS);
   free_alloc_pool (occ_pool);
+  return 0;
 }
 
 struct tree_opt_pass pass_cse_reciprocals =