]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/113898 - ICE with sanity checking for VN ref adjustment
authorRichard Biener <rguenther@suse.de>
Tue, 13 Feb 2024 09:04:31 +0000 (10:04 +0100)
committerRichard Biener <rguenther@suse.de>
Tue, 13 Feb 2024 10:45:24 +0000 (11:45 +0100)
The following fixes a missing add to the accumulated offset when
adjusting an ARRAY_REF op for value-ranges applied to by
get_ref_base_and_extent.

PR tree-optimization/113898
* tree-ssa-sccvn.cc (copy_reference_ops_from_ref): Add
missing accumulated off adjustment.

* gcc.dg/torture/pr113898.c: New testcase.

gcc/testsuite/gcc.dg/torture/pr113898.c [new file with mode: 0644]
gcc/tree-ssa-sccvn.cc

diff --git a/gcc/testsuite/gcc.dg/torture/pr113898.c b/gcc/testsuite/gcc.dg/torture/pr113898.c
new file mode 100644 (file)
index 0000000..6832a34
--- /dev/null
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+int a, d;
+unsigned **b;
+long c, f;
+long e[2][1];
+void g() {
+  int h = 0;
+  for (; h < 2; h++) {
+    e[h][d + **b + a] = c;
+    if (f)
+      for (;;)
+        ;
+  }
+}
+void main() {}
index 2823573b656e276e2836fbcc88516be1769c4d8a..5a49390a79cbb5187522827571b7215399996bc7 100644 (file)
@@ -1126,6 +1126,7 @@ copy_reference_ops_from_ref (tree ref, vec<vn_reference_op_s> *result)
                op.op0 = wide_int_to_tree (TREE_TYPE (op.op0),
                                           wi::to_poly_wide (op.op1) + idx);
              op.off = idx * elsz;
+             off += op.off;
            }
          else
            {