From: Richard Biener Date: Tue, 13 Feb 2024 09:04:31 +0000 (+0100) Subject: tree-optimization/113898 - ICE with sanity checking for VN ref adjustment X-Git-Tag: basepoints/gcc-15~1189 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af6d8d0cc1ac56eba55ef658c664236208f88169;p=thirdparty%2Fgcc.git tree-optimization/113898 - ICE with sanity checking for VN ref adjustment 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. --- diff --git a/gcc/testsuite/gcc.dg/torture/pr113898.c b/gcc/testsuite/gcc.dg/torture/pr113898.c new file mode 100644 index 000000000000..6832a3452718 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr113898.c @@ -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() {} diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 2823573b656e..5a49390a79cb 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -1126,6 +1126,7 @@ copy_reference_ops_from_ref (tree ref, vec *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 {