]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/114048 - ICE in copy_reference_ops_from_ref
authorRichard Biener <rguenther@suse.de>
Thu, 22 Feb 2024 13:22:29 +0000 (14:22 +0100)
committerRichard Biener <rguenther@suse.de>
Thu, 22 Feb 2024 14:47:38 +0000 (15:47 +0100)
The following adds another omission to the assert verifying we're
not running into spurious off == -1.

PR tree-optimization/114048
* tree-ssa-sccvn.cc (copy_reference_ops_from_ref): MEM_REF
can also produce -1 off.

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

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

diff --git a/gcc/testsuite/gcc.dg/torture/pr114048.c b/gcc/testsuite/gcc.dg/torture/pr114048.c
new file mode 100644 (file)
index 0000000..338000b
--- /dev/null
@@ -0,0 +1,25 @@
+/* { dg-do compile } */
+
+typedef struct {
+  void *child[2];
+  char otherbits;
+} critbit0_node;
+
+int allprefixed_traverse(char *top)
+{
+  if (top)
+    {
+      critbit0_node *q = (void *)top - 1;
+      int direction = 0;
+      for (;; ++direction)
+       switch (allprefixed_traverse(q->child[direction]))
+         {
+         case 1:
+           break;
+         case 0:
+           return 0;
+         default:
+           return 1;
+         }
+    }
+}
index 3e93685e80a6a2271cf7166cc610e217a045b77c..2587eb1c505279ef49514ec99ffe030ea32554c8 100644 (file)
@@ -1185,6 +1185,8 @@ copy_reference_ops_from_ref (tree ref, vec<vn_reference_op_s> *result)
              else
                {
                  gcc_assert (known_ne (op.off, -1)
+                             /* The constant offset can be -1.  */
+                             || op.opcode == MEM_REF
                              /* Out-of-bound indices can compute to
                                 a known -1 offset.  */
                              || ((op.opcode == ARRAY_REF