https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128818
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <[email protected]>: https://gcc.gnu.org/g:59412e46c04fc5a6142283983ae7f8ff3d520c88 commit r17-6407-g59412e46c04fc5a6142283983ae7f8ff3d520c88 Author: Richard Biener <[email protected]> Date: Tue Nov 17 15:51:51 2026 +0100 tree-optimization/128818 - wrong-code with VN skipping same-val store Similar issues as in PR128637 exist in the same-val store skipping code as noted by Sashiko. Two revolve around redundant store elimination so the correct action is to avoid same-val store skipping when searching for an earlier redundant store. Another is inserting into the hashtable with an earlier vuse when we skipped defs in vn_walk_cb_data::finish. This makes us no longer optimize the apparent redundant store in gcc.dg/tree-ssa/pr91091-2.c and rightfully so because removing the later store changes the effective type of the storage if the objects are at the same address. PR tree-optimization/128818 * tree-ssa-sccvn.cc (vn_reference_lookup_3): Avoid skipping same-val may-defs when doing redundant store elimination. (vn_walk_cb_data::finish): Also skip hashtable insertion when same-val stores were skipped. * gcc.dg/torture/pr128818-1.c: New testcase. * gcc.dg/torture/pr128818-2.c: Likewise. * gcc.dg/torture/pr128818-3.c: Likewise. * gcc.dg/tree-ssa/pr91091-2.c: Adjust.
