https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120043
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-15 branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:856c493db1d5e2fa9377f4a0c438afbcaf6c7e01 commit r15-9651-g856c493db1d5e2fa9377f4a0c438afbcaf6c7e01 Author: Richard Biener <rguent...@suse.de> Date: Thu May 8 10:05:42 2025 +0200 tree-optimization/120043 - bogus conditional store elimination The following fixes conditional store elimination to properly check for conditional stores to readonly memory which we can obviously not store to unconditionally. The tree_could_trap_p predicate used is only considering rvalues and the chosen approach mimics that of loop store motion. PR tree-optimization/120043 * tree-ssa-phiopt.cc (cond_store_replacement): Check whether the store is to readonly memory. * gcc.dg/torture/pr120043.c: New testcase. (cherry picked from commit 93586e5d51188bf71f4f8fae4ee94ff631740f24)