https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88788
prathamesh3492 at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|unassigned at gcc dot gnu.org |prathamesh3492 at gcc dot gnu.org --- Comment #7 from prathamesh3492 at gcc dot gnu.org --- Created attachment 45412 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45412&action=edit Untested fix Hi, The issue seems to be recursively calling malloc_candidate_p_1 with duplicate arguments, for example, with above test-case, it shows following trace: https://pastebin.com/tF5Qg06X We can see it is calling malloc_candidate_p_1 with resultobj_164=PHI<...> thrice because resultobj_164 appears 3 times as a phi-arg in: resultobj_165 = PHI <_12(12), resultobj_164(13), resultobj_164(14), resultobj_164(15)> I think it's more of a compile time hog rather than infinite recursion happening. To avoid that, I simply skipped walking over duplicate args in the phi in the attached patch: + bool skip_dup_arg = false; + for (unsigned j = i; j > 0; j--) + if (operand_equal_p (gimple_phi_arg_def (phi, j - 1), arg, 0)) + { + skip_dup_arg = true; + break; + } + if (skip_dup_arg) + continue; + which appears to compile both the tests again. I assume a phi stmt usually won't have more than 4 or 5 args, so the loop shouldn't be too slow in practice ? I will be grateful for any other suggestions. For the larger test-case it shows 164.08 wall seconds time for compilation. Thanks, Prathamesh