This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH v2] combine: perform jump threading at the end
- From: Ilya Leoshkevich <iii at linux dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: krebbel at linux dot ibm dot com, rdapp at linux dot ibm dot com, richard dot guenther at gmail dot com, segher at kernel dot crashing dot org, Ilya Leoshkevich <iii at linux dot ibm dot com>
- Date: Wed, 5 Sep 2018 14:00:59 +0200
- Subject: [PATCH v2] combine: perform jump threading at the end
gcc/ChangeLog:
2018-09-05 Ilya Leoshkevich <iii@linux.ibm.com>
PR target/80080
* combine.c (rest_of_handle_combine): Perform jump threading.
gcc/testsuite/ChangeLog:
2018-09-05 Ilya Leoshkevich <iii@linux.ibm.com>
PR target/80080
* gcc.target/s390/pr80080-4.c: New test.
---
gcc/combine.c | 10 ++++++++--
gcc/testsuite/gcc.target/s390/pr80080-4.c | 16 ++++++++++++++++
2 files changed, 24 insertions(+), 2 deletions(-)
create mode 100644 gcc/testsuite/gcc.target/s390/pr80080-4.c
diff --git a/gcc/combine.c b/gcc/combine.c
index a2649b6d5a1..818b4c5b77d 100644
--- a/gcc/combine.c
+++ b/gcc/combine.c
@@ -14960,10 +14960,16 @@ rest_of_handle_combine (void)
free_dominance_info (CDI_DOMINATORS);
timevar_push (TV_JUMP);
rebuild_jump_labels (get_insns ());
- cleanup_cfg (0);
- timevar_pop (TV_JUMP);
}
+ /* Combining insns can change basic blocks in a way that they end up
+ containing a single jump_insn. This creates an opportunity to improve code
+ with jump threading. */
+ cleanup_cfg (CLEANUP_THREADING);
+
+ if (rebuild_jump_labels_after_combine)
+ timevar_pop (TV_JUMP);
+
regstat_free_n_sets_and_refs ();
return 0;
}
diff --git a/gcc/testsuite/gcc.target/s390/pr80080-4.c b/gcc/testsuite/gcc.target/s390/pr80080-4.c
new file mode 100644
index 00000000000..91d31ec7845
--- /dev/null
+++ b/gcc/testsuite/gcc.target/s390/pr80080-4.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+/* { dg-options "-march=z196 -O2" } */
+
+extern void bar(int *mem);
+
+void foo4(int *mem)
+{
+ int oldval = 0;
+ if (!__atomic_compare_exchange_n (mem, (void *) &oldval, 1,
+ 1, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED))
+ {
+ bar (mem);
+ }
+}
+
+/* { dg-final { scan-assembler "\n\tlt\t.*\n\tjne\t(\\.L\\d+)\n(.*\n)*\tcs\t.*\n\tber\t%r14\n\\1:\n\tjg\tbar\n" } } */
--
2.18.0