aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-ccp.c
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-04-14 13:40:58 +0200
committerRichard Biener <rguenther@suse.de>2021-04-26 10:08:46 +0200
commit52a5515ed6619739eb122f05ce26057dd8b06fb6 (patch)
treece23cf5cca7daae1d47e61007eccfdbfe862fe13 /gcc/tree-ssa-ccp.c
parent297bfacdb448c0d29b8dfac2818350b90902bc75 (diff)
downloadgcc-52a5515ed6619739eb122f05ce26057dd8b06fb6.zip
gcc-52a5515ed6619739eb122f05ce26057dd8b06fb6.tar.gz
gcc-52a5515ed6619739eb122f05ce26057dd8b06fb6.tar.bz2
Simplify {gimplify_and_,}update_call_from_tree API
This removes update_call_from_tree in favor of gimplify_and_update_call_from_tree, removing some code duplication and simplifying the API use. Some users of update_call_from_tree have been transitioned to replace_call_with_value and the API and its dependences have been moved to gimple-fold.h. This shaves off another user of valid_gimple_rhs_p which is now only used from within gimple-fold.c and thus moved and made private. 2021-04-14 Richard Biener <rguenther@suse.de> * tree-ssa-propagate.h (valid_gimple_rhs_p): Remove. (update_gimple_call): Likewise. (update_call_from_tree): Likewise. * tree-ssa-propagate.c (valid_gimple_rhs_p): Remove. (valid_gimple_call_p): Likewise. (move_ssa_defining_stmt_for_defs): Likewise. (finish_update_gimple_call): Likewise. (update_gimple_call): Likewise. (update_call_from_tree): Likewise. (propagate_tree_value_into_stmt): Use replace_call_with_value. * gimple-fold.h (update_gimple_call): Declare. * gimple-fold.c (valid_gimple_rhs_p): Move here from tree-ssa-propagate.c. (update_gimple_call): Likewise. (valid_gimple_call_p): Likewise. (finish_update_gimple_call): Likewise, and simplify. (gimplify_and_update_call_from_tree): Implement update_call_from_tree functionality, avoid excessive push/pop_gimplify_context. (gimple_fold_builtin): Use only gimplify_and_update_call_from_tree. (gimple_fold_call): Likewise. * gimple-ssa-sprintf.c (try_substitute_return_value): Likewise. * tree-ssa-ccp.c (ccp_folder::fold_stmt): Likewise. (pass_fold_builtins::execute): Likewise. (optimize_stack_restore): Use replace_call_with_value. * tree-cfg.c (fold_loop_internal_call): Likewise. * tree-ssa-dce.c (maybe_optimize_arith_overflow): Use only gimplify_and_update_call_from_tree. * tree-ssa-strlen.c (handle_builtin_strlen): Likewise. (handle_builtin_strchr): Likewise. * tsan.c: Include gimple-fold.h instead of tree-ssa-propagate.h. * config/rs6000/rs6000-call.c (rs6000_gimple_fold_builtin): Use replace_call_with_value.
Diffstat (limited to 'gcc/tree-ssa-ccp.c')
-rw-r--r--gcc/tree-ssa-ccp.c15
1 files changed, 5 insertions, 10 deletions
diff --git a/gcc/tree-ssa-ccp.c b/gcc/tree-ssa-ccp.c
index 3bfd4a6..bf31f03 100644
--- a/gcc/tree-ssa-ccp.c
+++ b/gcc/tree-ssa-ccp.c
@@ -2332,12 +2332,10 @@ ccp_folder::fold_stmt (gimple_stmt_iterator *gsi)
&& (flags & ECF_LOOPING_CONST_OR_PURE) == 0)
{
tree new_rhs = unshare_expr (val);
- bool res;
if (!useless_type_conversion_p (TREE_TYPE (lhs),
TREE_TYPE (new_rhs)))
new_rhs = fold_convert (TREE_TYPE (lhs), new_rhs);
- res = update_call_from_tree (gsi, new_rhs);
- gcc_assert (res);
+ gimplify_and_update_call_from_tree (gsi, new_rhs);
return true;
}
@@ -2355,9 +2353,8 @@ ccp_folder::fold_stmt (gimple_stmt_iterator *gsi)
tree new_rhs = fold_builtin_alloca_with_align (stmt);
if (new_rhs)
{
- bool res = update_call_from_tree (gsi, new_rhs);
+ gimplify_and_update_call_from_tree (gsi, new_rhs);
tree var = TREE_OPERAND (TREE_OPERAND (new_rhs, 0),0);
- gcc_assert (res);
insert_clobbers_for_var (*gsi, var);
return true;
}
@@ -2382,8 +2379,7 @@ ccp_folder::fold_stmt (gimple_stmt_iterator *gsi)
&& ((TREE_INT_CST_LOW (ptrval.value) & (align - 1))
== (TREE_INT_CST_LOW (val.value) & (align - 1))))
{
- bool res = update_call_from_tree (gsi, ptr);
- gcc_assert (res);
+ replace_call_with_value (gsi, ptr);
return true;
}
}
@@ -2710,7 +2706,7 @@ optimize_stack_restore (gimple_stmt_iterator i)
stack_save_gsi = gsi_for_stmt (stack_save);
rhs = build_int_cst (TREE_TYPE (gimple_call_arg (call, 0)), 0);
- update_call_from_tree (&stack_save_gsi, rhs);
+ replace_call_with_value (&stack_save_gsi, rhs);
}
}
}
@@ -3434,8 +3430,7 @@ pass_fold_builtins::execute (function *fun)
continue;
}
- if (!update_call_from_tree (&i, result))
- gimplify_and_update_call_from_tree (&i, result);
+ gimplify_and_update_call_from_tree (&i, result);
}
todoflags |= TODO_update_address_taken;