https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84149
Martin Jambor <jamborm at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org --- Comment #4 from Martin Jambor <jamborm at gcc dot gnu.org> --- In my (more recent) checkout of trunk, the estimated benefit is even lower, only 270. Raising devirtualization hint to compensate seems excessive, I need: diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c index ee41a8d55b7..09ba92ef14d 100644 --- a/gcc/ipa-cp.c +++ b/gcc/ipa-cp.c @@ -2612,6 +2612,25 @@ devirtualization_time_bonus (struct cgraph_node *node, res += 7 / ((int)speculative + 1); } + if (res) + /* Devirtualization is likely more important in recursive callers because + those cannot be entirely inlined themselves. */ + for (cgraph_edge *e = node->callees; e; e = e->next_callee) + { + enum availability avail; + cgraph_node *callee = e->callee->function_symbol (&avail); + if (e->caller == callee + && avail >= AVAIL_AVAILABLE) + { + res = 8 * res; + + if (dump_file && (dump_flags & TDF_DETAILS)) + fprintf (dump_file, "Recursive devirtualization bohus %i\n", + res); + break; + } + } + return res; } Which is excessive (but it may make sense to boost IPA-CP bonuses for self-recursive functions a bit since those cannot be dealt with completely by inlining). Nevertless I already have a prototype patch which can explain to IPA-CP that only there is only one remaining value in the contexts for which we did not clone and replace it there too.