public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] tree-optimization/114048 - ICE in copy_reference_ops_from_ref
@ 2024-02-22 14:46 Richard Biener
  0 siblings, 0 replies; only message in thread
From: Richard Biener @ 2024-02-22 14:46 UTC (permalink / raw)
  To: gcc-patches

The following adds another omission to the assert verifying we're
not running into spurious off == -1.

Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed.

	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 | 25 +++++++++++++++++++++++++
 gcc/tree-ssa-sccvn.cc                   |  2 ++
 2 files changed, 27 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/torture/pr114048.c

diff --git a/gcc/testsuite/gcc.dg/torture/pr114048.c b/gcc/testsuite/gcc.dg/torture/pr114048.c
new file mode 100644
index 00000000000..338000b3006
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr114048.c
@@ -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;
+	  }
+    }
+}
diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc
index 3e93685e80a..2587eb1c505 100644
--- a/gcc/tree-ssa-sccvn.cc
+++ b/gcc/tree-ssa-sccvn.cc
@@ -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
-- 
2.35.3

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

only message in thread, other threads:[~2024-02-22 14:46 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-22 14:46 [PATCH] tree-optimization/114048 - ICE in copy_reference_ops_from_ref 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).