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;
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
/* 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)
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);
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);
+ }
}
}
/* 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;
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)
#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)
{
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)
}
}
- 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 =