https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88223
--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> --- OK, so the bug is in /* If we reach a clobbering statement try to skip it and see if we find a VN result with exactly the same value as the possible clobber. In this case we can ignore the clobber and return the found value. Note that we don't need to worry about partial overlapping accesses as we then can use TBAA to disambiguate against the clobbering statement when looking up a load (thus the VN_WALKREWRITE guard). */ if (vn_walk_kind == VN_WALKREWRITE && is_gimple_reg_type (TREE_TYPE (lhs)) && types_compatible_p (TREE_TYPE (lhs), vr->type)) { tree *saved_last_vuse_ptr = last_vuse_ptr; /* Do not update last_vuse_ptr in vn_reference_lookup_2. */ last_vuse_ptr = NULL; tree saved_vuse = vr->vuse; hashval_t saved_hashcode = vr->hashcode; void *res = vn_reference_lookup_2 (ref, gimple_vuse (def_stmt), 0, vr); /* Need to restore vr->vuse and vr->hashcode. */ vr->vuse = saved_vuse; vr->hashcode = saved_hashcode; last_vuse_ptr = saved_last_vuse_ptr; if (res && res != (void *)-1) { vn_reference_t vnresult = (vn_reference_t) res; if (vnresult->result && operand_equal_p (vnresult->result, gimple_assign_rhs1 (def_stmt), 0)) return res; } } where the "we don't need to worry about partial overlapping accesses" is of course wrong in the case of ref-all accesses.