On Wed, Sep 5, 2018 at 10:44 AM Ilya Leoshkevich <i...@linux.ibm.com> wrote: > > Combine 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.
Hmm, I think CFG cleanup performs this as well (if run in the correct mode) so maybe combine should invoke that? I don't think you should alter the pass pipeline this way in archtecture specific ways. Richard. > gcc/ChangeLog: > > 2018-08-28 Ilya Leoshkevich <i...@linux.ibm.com> > > PR target/80080 > * cfgcleanup.c: Make jump pass clonable. > * config/s390/s390-passes.def (INSERT_PASS_AFTER): Perform jump > threading after combine. > > gcc/testsuite/ChangeLog: > > 2018-08-28 Ilya Leoshkevich <i...@linux.ibm.com> > > PR target/80080 > * gcc.target/s390/pr80080-4.c: New test. > --- > gcc/cfgcleanup.c | 1 + > gcc/config/s390/s390-passes.def | 1 + > gcc/testsuite/gcc.target/s390/pr80080-4.c | 16 ++++++++++++++++ > 3 files changed, 18 insertions(+) > create mode 100644 gcc/testsuite/gcc.target/s390/pr80080-4.c > > diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c > index 4a5dc29d14f..35aa9f0ac4a 100644 > --- a/gcc/cfgcleanup.c > +++ b/gcc/cfgcleanup.c > @@ -3234,6 +3234,7 @@ public: > {} > > /* opt_pass methods: */ > + virtual opt_pass *clone () { return new pass_jump (m_ctxt); } > virtual unsigned int execute (function *); > > }; // class pass_jump > diff --git a/gcc/config/s390/s390-passes.def b/gcc/config/s390/s390-passes.def > index 035c6e8bc0a..2e9b208553e 100644 > --- a/gcc/config/s390/s390-passes.def > +++ b/gcc/config/s390/s390-passes.def > @@ -17,4 +17,5 @@ You should have received a copy of the GNU General Public > License > along with GCC; see the file COPYING3. If not see > <http://www.gnu.org/licenses/>. */ > > +INSERT_PASS_AFTER (pass_combine, 1, pass_jump); > INSERT_PASS_BEFORE (pass_thread_prologue_and_epilogue, 1, > pass_s390_early_mach); > 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 >