]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
avoid trying to set block in barriers [PR113506]
authorAlexandre Oliva <oliva@adacore.com>
Fri, 20 Dec 2024 21:01:53 +0000 (18:01 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Fri, 20 Dec 2024 21:01:53 +0000 (18:01 -0300)
When we emit a sequence before a preexisting insn and naming a BB to
store in the insns, we will attempt to store the BB even in barriers
present in the sequence.

Barriers don't expect blocks, and rtl checking catches the problem.

When emitting after a preexisting insn, we skip the block setting in
barriers.  Change the before emitter to do so as well.

for  gcc/ChangeLog

PR middle-end/113506
* emit-rtl.cc (add_insn_before): Don't set the block of a
barrier.

for  gcc/testsuite/ChangeLog

PR middle-end/113506
* gcc.target/riscv/pr113506.c: New.

gcc/emit-rtl.cc
gcc/testsuite/gcc.target/riscv/pr113506.c [new file with mode: 0644]

index a556692e8a02ad4a49e45956bcd5b1a3ec3595d9..3af6849a29bc619b1fc948586e31988aec58f0a8 100644 (file)
@@ -4369,9 +4369,11 @@ add_insn_before (rtx_insn *insn, rtx_insn *before, basic_block bb)
 {
   add_insn_before_nobb (insn, before);
 
+  if (BARRIER_P (insn))
+    return;
+
   if (!bb
-      && !BARRIER_P (before)
-      && !BARRIER_P (insn))
+      && !BARRIER_P (before))
     bb = BLOCK_FOR_INSN (before);
 
   if (bb)
diff --git a/gcc/testsuite/gcc.target/riscv/pr113506.c b/gcc/testsuite/gcc.target/riscv/pr113506.c
new file mode 100644 (file)
index 0000000..404dda9
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-fchecking=1 -Os -fno-tree-coalesce-vars -finline-stringops" } */
+
+typedef unsigned v32su __attribute__((vector_size (32)));
+
+v32su foo_v32su_4;
+
+unsigned
+foo (v32su v32su_2)
+{
+  v32su_2 *= v32su_2;
+  if (foo_v32su_4[3])
+    v32su_2 &= (v32su){};
+  return v32su_2[1];
+}