https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102513
--- Comment #12 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:cf68f5a6d20db2aee2f3e674ad3f10e1c458edf9 commit r12-7937-gcf68f5a6d20db2aee2f3e674ad3f10e1c458edf9 Author: Martin Jambor <mjam...@suse.cz> Date: Thu Mar 31 17:14:42 2022 +0200 ipa-cp: Do not create clones for values outside known value range (PR 102513) PR 102513 shows we emit bogus array access warnings when IPA-CP creates clones specialized for values which it deduces from arithmetic jump functions describing self-recursive calls. Those can however be avoided if we consult the IPA-VR information that the same pass also has. The patch below does that at the stage when normally values are only examined for profitability. It would be better not to create lattices describing such bogus values in the first place, however that presents an ordering problem, the pass currently propagates all information, and so both constants and VR, in no particular order when processing SCCs, and so this approach seemed much simpler. I plan to rearrange the pass so that it clones in multiple passes over the call graph (or rather the lattice dependence graph) and it feels natural to only do propagation for these kinds of recursion in the second or later passes, which would fix the issue more elegantly. gcc/ChangeLog: 2022-02-14 Martin Jambor <mjam...@suse.cz> PR ipa/102513 * ipa-cp.cc (decide_whether_version_node): Skip scalar values which do not fit the known value_range. gcc/testsuite/ChangeLog: 2022-02-14 Martin Jambor <mjam...@suse.cz> PR ipa/102513 * gcc.dg/ipa/pr102513.c: New test.