diff options
author | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-21 05:04:30 +0000 |
---|---|---|
committer | aoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-11-21 05:04:30 +0000 |
commit | 5fb3d93fced846c9ee5217c18591a7dc353fbd76 (patch) | |
tree | 45cdd369007484a44434fbf6ca63aa95185eabd6 /gcc/gimple.c | |
parent | 44dd08ba26cdff9d33fca80ae828ad59776c1d96 (diff) | |
download | gcc-5fb3d93fced846c9ee5217c18591a7dc353fbd76.tar.gz |
gcc/ChangeLog:
PR tree-optimization/42078
* gimple.h (gimple_replace_lhs): New declaration.
* gimple.c (gimple_replace_lhs): New function.
* tree-ssa-math-opts.c (execute_cse_reciprocals): Call it before
modifying the call.
gcc/testsuite/ChangeLog:
PR tree-optimization/42078
* gcc.dg/pr42078.c: New test.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154400 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gimple.c')
-rw-r--r-- | gcc/gimple.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/gimple.c b/gcc/gimple.c index 9cec865a728..f84a20cd6c1 100644 --- a/gcc/gimple.c +++ b/gcc/gimple.c @@ -1981,6 +1981,39 @@ gimple_set_lhs (gimple stmt, tree lhs) gcc_unreachable(); } +/* Replace the LHS of STMT, an assignment, either a GIMPLE_ASSIGN or a + GIMPLE_CALL, with NLHS, in preparation for modifying the RHS to an + expression with a different value. + + This will update any annotations (say debug bind stmts) referring + to the original LHS, so that they use the RHS instead. This is + done even if NLHS and LHS are the same, for it is understood that + the RHS will be modified afterwards, and NLHS will not be assigned + an equivalent value. + + Adjusting any non-annotation uses of the LHS, if needed, is a + responsibility of the caller. + + The effect of this call should be pretty much the same as that of + inserting a copy of STMT before STMT, and then removing the + original stmt, at which time gsi_remove() would have update + annotations, but using this function saves all the inserting, + copying and removing. */ + +void +gimple_replace_lhs (gimple stmt, tree nlhs) +{ + if (MAY_HAVE_DEBUG_STMTS) + { + tree lhs = gimple_get_lhs (stmt); + + gcc_assert (SSA_NAME_DEF_STMT (lhs) == stmt); + + insert_debug_temp_for_var_def (NULL, lhs); + } + + gimple_set_lhs (stmt, nlhs); +} /* Return a deep copy of statement STMT. All the operands from STMT are reallocated and copied using unshare_expr. The DEF, USE, VDEF |