aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-math-opts.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-ssa-math-opts.c')
-rw-r--r--gcc/tree-ssa-math-opts.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/gcc/tree-ssa-math-opts.c b/gcc/tree-ssa-math-opts.c
index ccff56f..d210777 100644
--- a/gcc/tree-ssa-math-opts.c
+++ b/gcc/tree-ssa-math-opts.c
@@ -652,8 +652,12 @@ optimize_recip_sqrt (gimple_stmt_iterator *def_gsi, tree def)
print_gimple_stmt (dump_file, stmt, 0, TDF_NONE);
fprintf (dump_file, "with new division\n");
}
- gimple_assign_set_lhs (stmt, sqr_ssa_name);
- gimple_assign_set_rhs2 (stmt, a);
+ stmt
+ = gimple_build_assign (sqr_ssa_name, gimple_assign_rhs_code (stmt),
+ gimple_assign_rhs1 (stmt), a);
+ gsi_insert_before (def_gsi, stmt, GSI_SAME_STMT);
+ gsi_remove (def_gsi, true);
+ *def_gsi = gsi_for_stmt (stmt);
fold_stmt_inplace (def_gsi);
update_stmt (stmt);
@@ -704,7 +708,7 @@ optimize_recip_sqrt (gimple_stmt_iterator *def_gsi, tree def)
gimple *new_stmt
= gimple_build_assign (x, MULT_EXPR,
- orig_sqrt_ssa_name, sqr_ssa_name);
+ orig_sqrt_ssa_name, sqr_ssa_name);
gsi_insert_after (def_gsi, new_stmt, GSI_NEW_STMT);
update_stmt (stmt);
}
@@ -715,6 +719,8 @@ optimize_recip_sqrt (gimple_stmt_iterator *def_gsi, tree def)
gsi_remove (&gsi2, true);
release_defs (stmt);
}
+ else
+ release_ssa_name (x);
}
/* Look for floating-point divisions among DEF's uses, and try to
@@ -951,6 +957,7 @@ pass_cse_reciprocals::execute (function *fun)
stmt = gsi_stmt (gsi);
if (flag_unsafe_math_optimizations
&& is_gimple_assign (stmt)
+ && gimple_assign_lhs (stmt) == def
&& !stmt_can_throw_internal (cfun, stmt)
&& gimple_assign_rhs_code (stmt) == RDIV_EXPR)
optimize_recip_sqrt (&gsi, def);