This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] combine: Emit a barrier after unconditional trap (PR78607)
- From: Segher Boessenkool <segher at kernel dot crashing dot org>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Segher Boessenkool <segher at kernel dot crashing dot org>
- Date: Thu, 1 Dec 2016 01:53:15 +0000
- Subject: [PATCH] combine: Emit a barrier after unconditional trap (PR78607)
- Authentication-results: sourceware.org; auth=none
After an unconditional trap there should be a barrier. In most cases
one is automatically inserted, but not if the trap is the final insn in
the instruction stream. We need to emit one explicitly.
Tested on powerpc64-linux {-m64,-m32}, committing to trunk.
Segher
2016-12-01 Segher Boessenkool <segher@kernel.crashing.org>
PR rtl-optimization/78607
* combine.c (try_combine): Emit a barrier after a unconditional trap.
gcc/testsuite/
PR rtl-optimization/78607
* gcc.c-torture/compile/pr78607.c: New testcase.
---
gcc/combine.c | 2 ++
gcc/testsuite/gcc.c-torture/compile/pr78607.c | 12 ++++++++++++
2 files changed, 14 insertions(+)
create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr78607.c
diff --git a/gcc/combine.c b/gcc/combine.c
index fd33a4d..e48b6c9 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -4655,6 +4655,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
basic_block bb = BLOCK_FOR_INSN (i3);
gcc_assert (bb);
remove_edge (split_block (bb, i3));
+ emit_barrier_after_bb (bb);
*new_direct_jump_p = 1;
}
@@ -4665,6 +4666,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0,
basic_block bb = BLOCK_FOR_INSN (undobuf.other_insn);
gcc_assert (bb);
remove_edge (split_block (bb, undobuf.other_insn));
+ emit_barrier_after_bb (bb);
*new_direct_jump_p = 1;
}
diff --git a/gcc/testsuite/gcc.c-torture/compile/pr78607.c b/gcc/testsuite/gcc.c-torture/compile/pr78607.c
new file mode 100644
index 0000000..2c5420d
--- /dev/null
+++ b/gcc/testsuite/gcc.c-torture/compile/pr78607.c
@@ -0,0 +1,12 @@
+/* PR rtl-optimization/78607 */
+
+void
+rc (int cx)
+{
+ int mq;
+
+ if (mq == 0 && (cx / 0) != 0)
+ for (;;)
+ {
+ }
+}
--
1.9.3