public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r14-8950] tree-optimization/113898 - ICE with sanity checking for VN ref adjustment
@ 2024-02-13 10:45 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-02-13 10:45 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:af6d8d0cc1ac56eba55ef658c664236208f88169

commit r14-8950-gaf6d8d0cc1ac56eba55ef658c664236208f88169
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Feb 13 10:04:31 2024 +0100

    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:
---
 gcc/testsuite/gcc.dg/torture/pr113898.c | 16 ++++++++++++++++
 gcc/tree-ssa-sccvn.cc                   |  1 +
 2 files changed, 17 insertions(+)

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<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
 	    {

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-02-13 10:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 10:45 [gcc r14-8950] tree-optimization/113898 - ICE with sanity checking for VN ref adjustment Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).