aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-range-cache.cc
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2022-12-16 16:53:31 -0500
committerAndrew MacLeod <amacleod@redhat.com>2022-12-20 09:15:23 -0500
commit0bdd2261c254f08b0f4437c156b79711d68c6e7f (patch)
tree44d559b9833295b7b2c2eb709e309644a1f82144 /gcc/gimple-range-cache.cc
parent05b7cf52e1b640271900894a894da2d27ef90092 (diff)
downloadgcc-0bdd2261c254f08b0f4437c156b79711d68c6e7f.zip
gcc-0bdd2261c254f08b0f4437c156b79711d68c6e7f.tar.gz
gcc-0bdd2261c254f08b0f4437c156b79711d68c6e7f.tar.bz2
Don't use PHI equivalences in range-on-entry.
If there is only one argument to a PHI which is defined, an equivalency is created between the def and the argument. It is safe to consider the def equal to the argument, but it is dangerous to assume the argument is also equivalent to the def as there may be branches which change the range on the path to the PHI on that argument This patch avoid using that relation in range-on-entry calculations. PR tree-optimization/108139 gcc/ * gimple-range-cache.cc (ranger_cache::fill_block_cache): Do not use equivalences originating from PHIS. gcc/testsuite/ * gcc.dg/pr108139.c: New.
Diffstat (limited to 'gcc/gimple-range-cache.cc')
-rw-r--r--gcc/gimple-range-cache.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index ce5a0c8..9848d14 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1235,6 +1235,13 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb)
if (!m_gori.has_edge_range_p (equiv_name))
continue;
+ // PR 108139. It is hazardous to assume an equivalence with
+ // a PHI is the same value. The PHI may be an equivalence
+ // via UNDEFINED arguments which is really a one way equivalence.
+ // PHIDEF == name, but name may not be == PHIDEF.
+ if (is_a<gphi *> (SSA_NAME_DEF_STMT (equiv_name)))
+ continue;
+
// Check if the equiv definition dominates this block
if (equiv_bb == bb ||
(equiv_bb && !dominated_by_p (CDI_DOMINATORS, bb, equiv_bb)))