https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121740
--- Comment #5 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:95afbe4c7633459b59d434550888decc41b4d44f commit r16-3561-g95afbe4c7633459b59d434550888decc41b4d44f Author: Richard Biener <rguent...@suse.de> Date: Wed Sep 3 12:54:58 2025 +0200 tree-optimization/121740 - handle aggregate zeroing as skipped may-def The following makes value-numbering handle a situation like D.58046 = {}; SR.83_44->i = {}; pretmp_41 = MEM[(struct _Optional_payload_base &)&D.58046 + 8]._M_engaged; where the intermediate may-def SR.83_44->i = {} prevents CSE of the load to zero. The problem is two-fold here, one is that the code skipping may-defs does not handle zeroing via a CTOR, the other is that (partial) must-defs can be better handled by later code as otherwise we may not find an appropriate definition to CSE to. I've noticed we fail to guard against storage-order issues, so fixed that on the fly. PR tree-optimization/121740 * tree-ssa-sccvn.cc (vn_reference_lookup_3): Allow skipping may-defs from CTORs. Do not skip may-defs with storage-order issues or (partial) must-defs. * gcc.dg/tree-ssa/ssa-fre-104.c: Un-XFAIL. * gcc.dg/tree-ssa/ssa-fre-110.c: New testcase.