https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102513
--- Comment #8 from Martin Jambor <jamborm at gcc dot gnu.org> --- I am about to thest the following patch. In longer-run, it would be better to never generate lattice values outside of the value_range but there is an ordering problem, we need the complete VR info before we can use it. I plan to rearrange IPA-CP into making multiple passes over the lattice dependency graph and this should quite naturally be solved by doing this kind of resursive-value-generation only in second and later passes. diff --git a/gcc/ipa-cp.cc b/gcc/ipa-cp.cc index 453e9c93cc3..cbbb8bbc80a 100644 --- a/gcc/ipa-cp.cc +++ b/gcc/ipa-cp.cc @@ -6154,8 +6154,16 @@ decide_whether_version_node (struct cgraph_node *node) { ipcp_value<tree> *val; for (val = lat->values; val; val = val->next) - ret |= decide_about_value (node, i, -1, val, &avals, - &self_gen_clones); + { + if (!plats->m_value_range.bottom_p () + && !plats->m_value_range.m_vr.contains_p (val->value)) + { + gcc_checking_assert (val->self_recursion_generated_p ()); + continue; + } + ret |= decide_about_value (node, i, -1, val, &avals, + &self_gen_clones); + } } if (!plats->aggs_bottom)