https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104813
--- Comment #5 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Martin Jambor <jamb...@gcc.gnu.org>: https://gcc.gnu.org/g:e671e48e352ee278d816d4633146208807a0e403 commit r12-7593-ge671e48e352ee278d816d4633146208807a0e403 Author: Martin Jambor <mjam...@suse.cz> Date: Thu Mar 10 14:49:23 2022 +0100 ipa-cp: Avoid adjusting references through self-recursion (PR 104813) When writing the patch that downgrades address-taken references to load references when IPA-CP can prove that all uses of the taken address ends up in loads, I unfortunately did not take into account that find_more_scalar_values_for_callers_subset now happily adds self-recursive edges to the set of callers which should be immediately redirected (originally recursion was meant to be handled as edge redirection in a second pass over the SCC). The code as it is can now decrement the referece counters too many times. This can remedied by removing self-recursive edges earlier, we already do it because of thunk expansion issues, and so this patch does exactly that. gcc/ChangeLog: 2022-03-07 Martin Jambor <mjam...@suse.cz> PR ipa/104813 * ipa-cp.cc (create_specialized_node): Move removal of self-recursive calls from callers vector before refrence adjustments. gcc/testsuite/ChangeLog: 2022-03-07 Martin Jambor <mjam...@suse.cz> PR ipa/104813 * gcc.dg/ipa/pr104813.c: New test.