]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
rtl-ssa: Fix removal of order_nodes [PR115929]
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 16 Jul 2024 14:33:23 +0000 (15:33 +0100)
committerRichard Sandiford <richard.sandiford@arm.com>
Tue, 16 Jul 2024 14:33:23 +0000 (15:33 +0100)
order_nodes are used to implement ordered comparisons between
two insns with the same program point number.  remove_insn would
remove an order_node from its splay tree, but didn't remove it
from the insn.  This caused confusion if the insn was later
reinserted somewhere else that also needed an order_node.

gcc/
PR rtl-optimization/115929
* rtl-ssa/insns.cc (function_info::remove_insn): Remove an
order_node from the instruction as well as from the splay tree.

gcc/testsuite/
PR rtl-optimization/115929
* gcc.dg/torture/pr115929-1.c: New test.

gcc/rtl-ssa/insns.cc
gcc/testsuite/gcc.dg/torture/pr115929-1.c [new file with mode: 0644]

index 7e26bfd978fef34088eb4bb7272e19e3d2948c11..bc30734df89fe21a4e16f2bf1c9960d732bc6fc9 100644 (file)
@@ -393,7 +393,10 @@ void
 function_info::remove_insn (insn_info *insn)
 {
   if (insn_info::order_node *order = insn->get_order_node ())
-    insn_info::order_splay_tree::remove_node (order);
+    {
+      insn_info::order_splay_tree::remove_node (order);
+      insn->remove_note (order);
+    }
 
   if (auto *note = insn->find_note<insn_call_clobbers_note> ())
     {
diff --git a/gcc/testsuite/gcc.dg/torture/pr115929-1.c b/gcc/testsuite/gcc.dg/torture/pr115929-1.c
new file mode 100644 (file)
index 0000000..19b831a
--- /dev/null
@@ -0,0 +1,45 @@
+/* { dg-require-effective-target lp64 } */
+/* { dg-options "-fno-gcse -fschedule-insns -fno-guess-branch-probability -fno-tree-fre -fno-tree-ch" } */
+
+int printf(const char *, ...);
+int a[6], b, c;
+char d, l;
+struct {
+  char e;
+  int f;
+  int : 8;
+  long g;
+  long h;
+} i[1][9] = {0};
+unsigned j;
+void n(char p) { b = b >> 8 ^ a[b ^ p]; }
+int main() {
+  int k, o;
+  while (b) {
+    k = 0;
+    for (; k < 9; k++) {
+      b = b ^ a[l];
+      n(j);
+      if (o)
+        printf(&d);
+      long m = i[c][k].f;
+      b = b >> 8 ^ a[l];
+      n(m >> 32);
+      n(m);
+      if (o)
+        printf("%d", d);
+      b = b >> 8 ^ l;
+      n(2);
+      n(0);
+      if (o)
+        printf(&d);
+      b = b ^ a[l];
+      n(i[c][k].g >> 2);
+      n(i[c][k].g);
+      if (o)
+        printf(&d);
+      printf("%d", i[c][k].f);
+    }
+  }
+  return 0;
+}