https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115579
--- Comment #9 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:8a1795bddcd34284936af4706f762d89c60fc69c commit r15-1564-g8a1795bddcd34284936af4706f762d89c60fc69c Author: Richard Biener <rguent...@suse.de> Date: Sat Jun 22 14:59:09 2024 +0200 tree-optimization/115579 - fix wrong code with store-motion The recent change to relax store motion for variables that cannot have store data races broke the optimization to share flag vars for stores that all happen in the same single BB. The following fixes this. PR tree-optimization/115579 * tree-ssa-loop-im.cc (execute_sm): Return the auxiliary data created. (hoist_memory_references): Record the flag var that's eventually created and re-use it when all stores are in the same BB. * gcc.dg/pr115579.c: New testcase.