aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew MacLeod <amacleod@redhat.com>2023-08-16 13:23:06 -0400
committerAndrew MacLeod <amacleod@redhat.com>2023-08-23 14:40:55 -0400
commite5f83a200702466adbfdedd57aa2e9e5acb8953d (patch)
treee3f649b881afb73bd18694550b1c4c157b764b9f
parentbf64392d66f2913d2bbd1d3232f7f8a77c812d13 (diff)
downloadgcc-e5f83a200702466adbfdedd57aa2e9e5acb8953d.zip
gcc-e5f83a200702466adbfdedd57aa2e9e5acb8953d.tar.gz
gcc-e5f83a200702466adbfdedd57aa2e9e5acb8953d.tar.bz2
Don't process phi groups with one phi.
The phi analyzer should not create a phi group containing a single phi. * gimple-range-phi.cc (phi_analyzer::operator[]): Return NULL if no group was created. (phi_analyzer::process_phi): Do not create groups of one phi node.
-rw-r--r--gcc/gimple-range-phi.cc16
1 files changed, 11 insertions, 5 deletions
diff --git a/gcc/gimple-range-phi.cc b/gcc/gimple-range-phi.cc
index ffb4691..a94b90a 100644
--- a/gcc/gimple-range-phi.cc
+++ b/gcc/gimple-range-phi.cc
@@ -344,9 +344,10 @@ phi_analyzer::operator[] (tree name)
process_phi (as_a<gphi *> (SSA_NAME_DEF_STMT (name)));
if (bitmap_bit_p (m_simple, v))
return NULL;
- // If m_simple bit isn't set, then process_phi allocated the table
- // and should have a group.
- gcc_checking_assert (v < m_tab.length ());
+ // If m_simple bit isn't set, and process_phi didn't allocated the table
+ // no group was created, so return NULL.
+ if (v >= m_tab.length ())
+ return NULL;
}
return m_tab[v];
}
@@ -363,6 +364,7 @@ phi_analyzer::process_phi (gphi *phi)
unsigned x;
m_work.truncate (0);
m_work.safe_push (gimple_phi_result (phi));
+ unsigned phi_count = 1;
bitmap_clear (m_current);
// We can only have 2 externals: an initial value and a modifier.
@@ -407,6 +409,7 @@ phi_analyzer::process_phi (gphi *phi)
gimple *arg_stmt = SSA_NAME_DEF_STMT (arg);
if (arg_stmt && is_a<gphi *> (arg_stmt))
{
+ phi_count++;
m_work.safe_push (arg);
continue;
}
@@ -430,9 +433,12 @@ phi_analyzer::process_phi (gphi *phi)
}
}
- // If there are no names in the group, we're done.
- if (bitmap_empty_p (m_current))
+ // If there are less than 2 names, just return. This PHI may be included
+ // by another PHI, making it simple or a group of one will prevent a larger
+ // group from being formed.
+ if (phi_count < 2)
return;
+ gcc_checking_assert (!bitmap_empty_p (m_current));
phi_group *g = NULL;
if (cycle_p)