https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124424
Richard Biener <rguenth at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Keywords| |compile-time-hog
Ever confirmed|0 |1
Status|UNCONFIRMED |NEW
Last reconfirmed| |2026-03-10
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
So we're recursing via
static void
back_propagate_equivalences (tree lhs, edge e,
class avail_exprs_stack *avail_exprs_stack,
class const_and_copies *const_and_copies,
bitmap domby)
{
...
/* Iterate over the uses of LHS to see if any dominate E->dest.
If so, they may create useful equivalences too.
??? If the code gets re-organized to a worklist to catch more
indirect opportunities and it is made to handle PHIs then this
should only consider use_stmts in basic-blocks we have already visited.
*/
FOR_EACH_IMM_USE_FAST (use_p, iter, lhs)
{
gimple *use_stmt = USE_STMT (use_p);
...
/* Filter out statements that can never produce a useful
equivalence. */
tree lhs2 = gimple_get_lhs (use_stmt);
...
/* It may also be the case that the value is in the hash table. So
try to look it up there too. But restrict ourselves to cases where
the hash lookup produced a constant rather than another SSA_NAME.
That avoids infinite recursion issues. */
res = avail_exprs_stack->lookup_avail_expr (use_stmt, false, false);
if (res && is_gimple_min_invariant (res))
{
record_equality (lhs2, res, const_and_copies);
/* And that in turn may trigger further propagation opportunities.
*/
back_propagate_equivalences (lhs2, e, avail_exprs_stack,
const_and_copies, domby);
first, while unlikely, a use_stmt can be reached from different LHS, so
given the lack of a 'we have visited use_stmt' this looks prone to
exponential behavior.
The actual recursion issue (it doesn't look too deep?) could be easily
solved by using a worklist of lhs2.
The reduced testcase doesn't seem to crash for me but it runs forever, so
likely the first issue. Yep, we're hitting SSA name 50 repeatedly, possibly
even via a cycle as you are using gimple_get_lhs which happily handles PHIs.