The following avoids ending up with a MEM_REF as component to apply. Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.
* tree-ssa-sccvn.cc (vn_reference_lookup_3): When we fail to match up the two base MEM_REFs, fail. --- gcc/tree-ssa-sccvn.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 61d794d8407..cdd7c0542ad 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -3631,7 +3631,12 @@ vn_reference_lookup_3 (ao_ref *ref, tree vuse, void *data_, { extra_off = vr->operands[i].off - lhs_ops[j].off; i--, j--; + found = true; } + /* If we did find a match we'd eventually append a MEM_REF + as component. Don't. */ + if (!found) + return (void *)-1; } else return (void *)-1; -- 2.43.0