for gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
PR tree-optimization/42078
* tree-ssa-math-opts.c (execute_cse_reciprocals): Compute reciprocal
value for debug stmts.
===================================================================
@@ -574,6 +574,7 @@ execute_cse_reciprocals (void)
bool md_code, fail;
imm_use_iterator ui;
use_operand_p use_p;
+ tree value;
code = DECL_FUNCTION_CODE (fndecl);
md_code = DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_MD;
@@ -603,13 +604,24 @@ execute_cse_reciprocals (void)
if (fail)
continue;
- gimple_replace_lhs (stmt1, arg1, NULL);
+ if (gimple_replace_lhs_wants_value ())
+ {
+ tree t = TREE_TYPE (arg1);
+
+ value = build2 (RDIV_EXPR, t, build_one_cst (t), arg1);
+ }
+ else
+ value = NULL;
+
+ gimple_replace_lhs (stmt1, arg1, value);
gimple_call_set_fndecl (stmt1, fndecl);
update_stmt (stmt1);
reciprocal_stats.rfuncs_inserted++;
FOR_EACH_IMM_USE_STMT (stmt, ui, arg1)
{
+ if (is_gimple_debug (stmt))
+ continue;
gimple_assign_set_rhs_code (stmt, MULT_EXPR);
fold_stmt_inplace (stmt);
update_stmt (stmt);