There's a typo in the check against unknown offset when processing
an aggregate copy during VN, leading to wrong lookup.
PR tree-optimization/123310
* tree-ssa-sccvn.cc (vn_reference_lookup_3): Properly
test against unknown offset.
* gcc.dg/torture/pr123310.c: New testcase.
--- /dev/null
+/* { dg-do run } */
+
+struct a {
+ short b;
+} c[7], e;
+int d;
+static struct a f[3][2] = {{}, {}, 5, 5};
+void __attribute__((noipa)) g()
+{
+ for (; e.b >= 0; e.b--)
+ {
+ c[e.b + 6] = f[2][1];
+ d = c[6].b;
+ }
+}
+int main()
+{
+ g();
+ if (d != 5)
+ __builtin_abort ();
+}
via extra_off. Note this is an attempt to fixup secondary
copies after we hit the !found && j == 0 case above. */
while (j != -1
- && known_ne (lhs_ops[j].off, -1U))
+ && known_ne (lhs_ops[j].off, -1))
{
extra_off += -lhs_ops[j].off;
j--;