https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105937
--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-12 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:627132c9bf9439bf0ac83bb092182055c1e0f3ab commit r12-8818-g627132c9bf9439bf0ac83bb092182055c1e0f3ab Author: Richard Biener <rguent...@suse.de> Date: Fri Aug 19 14:12:52 2022 +0200 tree-optimization/105937 - avoid uninit diagnostics crossing iterations The following avoids adding PHIs to the worklist for uninit processing if we reach them following backedges. That confuses predicate analysis because it assumes the use is happening in the same iteration as the the definition. For the testcase in the PR the situation is like void foo (int val) { int uninit; # val = PHI <..> (B) for (..) { if (..) { .. = val; (C) val = uninit; } # val = PHI <..> (A) } } and starting from (A) with 'uninit' as argument we arrive at (B) and from there at (C). Predicate analysis then tries to prove the predicate of (B) (not the backedge) can prove that the path from (B) to (C) is unreachable which isn't really what it necessary - that's what we'd need to do when the preheader edge of the loop were the edge with the uninitialized def. So the following makes those cases intentionally false negatives. PR tree-optimization/105937 * tree-ssa-uninit.cc (find_uninit_use): Do not queue PHIs on backedges. (execute_late_warn_uninitialized): Mark backedges. * g++.dg/uninit-pr105937.C: New testcase. (cherry picked from commit c77fae1ca796d6ea06d5cd437909905c3d3d771c)