aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-ssa-phiopt.cc
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2022-12-23 16:19:08 +0100
committerJakub Jelinek <jakub@redhat.com>2022-12-23 16:19:08 +0100
commit3d6bb832022160b00e7001ac5b467e201ab4a9ac (patch)
treeb0d24c84dfa56e5d2133a69ad51c1c20a6c08a5f /gcc/tree-ssa-phiopt.cc
parentfd1b0aefda5b65f3f841ca6e61ccea6a72daa060 (diff)
downloadgcc-3d6bb832022160b00e7001ac5b467e201ab4a9ac.zip
gcc-3d6bb832022160b00e7001ac5b467e201ab4a9ac.tar.gz
gcc-3d6bb832022160b00e7001ac5b467e201ab4a9ac.tar.bz2
phiopt: Improve value_replacement maybe equal phires range handling
My previous patch added throwing away of SSA_NAME_RANGE_INFO of phires when we have phires = x != carg ? x : oarg, but that could throw away useful range info, all we need is merge phires current range info with the carg constant which can newly appear there (and the optimization proved the single user doesn't care about that). 2022-12-23 Jakub Jelinek <jakub@redhat.com> Aldy Hernandez <aldyh@redhat.com> * tree-ssa-phiopt.cc (value_replacement): Instead of resetting phires range info, union it with carg.
Diffstat (limited to 'gcc/tree-ssa-phiopt.cc')
-rw-r--r--gcc/tree-ssa-phiopt.cc24
1 files changed, 19 insertions, 5 deletions
diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index 906b406..59dc21c 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -1492,11 +1492,25 @@ value_replacement (basic_block cond_bb, basic_block middle_bb,
break;
}
if (equal_p)
- /* After the optimization PHI result can have value
- which it couldn't have previously.
- We could instead of resetting it union the range
- info with oarg. */
- reset_flow_sensitive_info (gimple_phi_result (phi));
+ {
+ tree phires = gimple_phi_result (phi);
+ if (SSA_NAME_RANGE_INFO (phires))
+ {
+ /* After the optimization PHI result can have value
+ which it couldn't have previously. */
+ int_range_max r;
+ if (get_global_range_query ()->range_of_expr (r, phires,
+ phi))
+ {
+ int_range<2> tmp (carg, carg);
+ r.union_ (tmp);
+ reset_flow_sensitive_info (phires);
+ set_range_info (phires, r);
+ }
+ else
+ reset_flow_sensitive_info (phires);
+ }
+ }
if (equal_p && MAY_HAVE_DEBUG_BIND_STMTS)
{
imm_use_iterator imm_iter;