https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106187
--- Comment #45 from Richard Earnshaw <rearnsha at gcc dot gnu.org> --- The problem with changing rtx_equal_for_cselib_1 is that it is essentially commutative in its operands - it doesn't disambiguate with x substituting for y or vice-versa, so we cannot tell if an operation is a load or a store. A minimal fix, which just suppresses stores would be: @@ -81,6 +81,10 @@ reload_cse_noop_set_p (rtx set) if (cselib_reg_set_mode (SET_DEST (set)) != GET_MODE (SET_DEST (set))) return 0; + /* Fixme: we need to check that removing a store doesn't change + the alias computations. */ + if (flag_strict_aliasing && MEM_P (SET_DEST (set))) + return 0; return rtx_equal_for_cselib_p (SET_DEST (set), SET_SRC (set)); } But we could no-doubt improve on that.