aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Sandiford <richard.sandiford@arm.com>2024-07-16 15:33:23 +0100
committerRichard Sandiford <richard.sandiford@arm.com>2024-07-16 15:33:23 +0100
commitfec38d7987dd6d68b234b0076b57ac66a30a3a1d (patch)
tree2d9a058b9228e37bc29f63ac0dc92a6f2b0085b0 /gcc
parent851ec9960b084ad37556ec627e6931e985e41a24 (diff)
downloadgcc-fec38d7987dd6d68b234b0076b57ac66a30a3a1d.zip
gcc-fec38d7987dd6d68b234b0076b57ac66a30a3a1d.tar.gz
gcc-fec38d7987dd6d68b234b0076b57ac66a30a3a1d.tar.bz2
rtl-ssa: Fix removal of order_nodes [PR115929]
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.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rtl-ssa/insns.cc5
-rw-r--r--gcc/testsuite/gcc.dg/torture/pr115929-1.c45
2 files changed, 49 insertions, 1 deletions
diff --git a/gcc/rtl-ssa/insns.cc b/gcc/rtl-ssa/insns.cc
index 7e26bfd..bc30734 100644
--- a/gcc/rtl-ssa/insns.cc
+++ b/gcc/rtl-ssa/insns.cc
@@ -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
index 0000000..19b831a
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/torture/pr115929-1.c
@@ -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;
+}