https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111422
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:ab25eef36400e8c1d28e3ed059c5f95a38b45f17 commit r15-517-gab25eef36400e8c1d28e3ed059c5f95a38b45f17 Author: Richard Biener <rguent...@suse.de> Date: Wed May 15 13:06:30 2024 +0200 middle-end/111422 - wrong stack var coalescing, handle PHIs The gcc.c-torture/execute/pr111422.c testcase after installing the sink pass improvement reveals that we also need to handle _65 = &g + _58; _44 = &g + _43; # _59 = PHI <_65, _44> *_59 = 8; g = {v} {CLOBBER(eos)}; ... n[0] = &f; *_59 = 8; g = {v} {CLOBBER(eos)}; where we fail to see the conflict between n and g after the first clobber of g. Before the sinking improvement there was a conflict recorded on a path where _65/_44 are unused, so the real conflict was missed but the fake one avoided the miscompile. The following handles PHI defs in add_scope_conflicts_2 which fixes the issue. PR middle-end/111422 * cfgexpand.cc (add_scope_conflicts_2): Handle PHIs by recursing to their arguments.