From: Ilya Leoshkevich Date: Mon, 3 Dec 2018 09:49:02 +0000 (+0000) Subject: Repeat jump threading after combine X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=98fe146e5be55232c20ef242ee7c7e2123373df4;p=gcc.git Repeat jump threading after combine Consider the following RTL: (insn (set (reg 65) (if_then_else (eq %cc 0) 1 0))) (insn (parallel [(set %cc (compare (reg 65) 0)) (clobber %scratch)])) (jump_insn (set %pc (if_then_else (ne %cc 0) (label_ref 23) %pc))) Combine simplifies this into: (note NOTE_INSN_DELETED) (note NOTE_INSN_DELETED) (jump_insn (set %pc (if_then_else (eq %cc 0) (label_ref 23) %pc))) opening up the possibility to perform jump threading. gcc/ChangeLog: 2018-12-03 Ilya Leoshkevich PR target/80080 * cfgcleanup.c (class pass_postreload_jump): New pass. (pass_postreload_jump::execute): Likewise. (make_pass_postreload_jump): Likewise. * passes.def: Add pass_postreload_jump before pass_postreload_cse. * tree-pass.h (make_pass_postreload_jump): New pass. gcc/testsuite/ChangeLog: 2018-12-03 Ilya Leoshkevich PR target/80080 * gcc.target/s390/pr80080-4.c: New test. From-SVN: r266734 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 109566e3703..3d8c5503ebe 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2018-12-03 Ilya Leoshkevich + + PR target/80080 + * cfgcleanup.c (class pass_postreload_jump): New pass. + (pass_postreload_jump::execute): Likewise. + (make_pass_postreload_jump): Likewise. + * passes.def: Add pass_postreload_jump before + pass_postreload_cse. + * tree-pass.h (make_pass_postreload_jump): New pass. + 2018-12-02 Uros Bizjak * config/i386/i386.c (inline_memory_move_cost): Correctly diff --git a/gcc/cfgcleanup.c b/gcc/cfgcleanup.c index 4a5dc29d14f..bc4a78889db 100644 --- a/gcc/cfgcleanup.c +++ b/gcc/cfgcleanup.c @@ -3259,6 +3259,48 @@ make_pass_jump (gcc::context *ctxt) namespace { +const pass_data pass_data_postreload_jump = +{ + RTL_PASS, /* type */ + "postreload_jump", /* name */ + OPTGROUP_NONE, /* optinfo_flags */ + TV_JUMP, /* tv_id */ + 0, /* properties_required */ + 0, /* properties_provided */ + 0, /* properties_destroyed */ + 0, /* todo_flags_start */ + 0, /* todo_flags_finish */ +}; + +class pass_postreload_jump : public rtl_opt_pass +{ +public: + pass_postreload_jump (gcc::context *ctxt) + : rtl_opt_pass (pass_data_postreload_jump, ctxt) + {} + + /* opt_pass methods: */ + virtual unsigned int execute (function *); + +}; // class pass_postreload_jump + +unsigned int +pass_postreload_jump::execute (function *) +{ + cleanup_cfg (flag_thread_jumps ? CLEANUP_THREADING : 0); + return 0; +} + +} // anon namespace + +rtl_opt_pass * +make_pass_postreload_jump (gcc::context *ctxt) +{ + return new pass_postreload_jump (ctxt); +} + +namespace { + const pass_data pass_data_jump2 = { RTL_PASS, /* type */ diff --git a/gcc/passes.def b/gcc/passes.def index 82ad9404b9e..0079fecef32 100644 --- a/gcc/passes.def +++ b/gcc/passes.def @@ -458,6 +458,7 @@ along with GCC; see the file COPYING3. If not see NEXT_PASS (pass_reload); NEXT_PASS (pass_postreload); PUSH_INSERT_PASSES_WITHIN (pass_postreload) + NEXT_PASS (pass_postreload_jump); NEXT_PASS (pass_postreload_cse); NEXT_PASS (pass_gcse2); NEXT_PASS (pass_split_after_reload); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 209b0934078..a2271703003 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-12-03 Ilya Leoshkevich + + PR target/80080 + * gcc.target/s390/pr80080-4.c: New test. + 2018-12-02 Andi Kleen * gcc.target/i386/returninst1.c: Run on 64bit only. 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..5fc6a558008 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/pr80080-4.c @@ -0,0 +1,16 @@ +/* { dg-do compile { target { lp64 } } } */ +/* { 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)\n\tlt\t.*\n\tjne\t(\.L\d+)\n(.*\n)*\tcs\t.*\n\tber\t%r14\n\1:\n\tjg\tbar\n} } } */ diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h index 2f8779ee4b8..b20d34c15e9 100644 --- a/gcc/tree-pass.h +++ b/gcc/tree-pass.h @@ -579,6 +579,7 @@ extern rtl_opt_pass *make_pass_clean_state (gcc::context *ctxt); extern rtl_opt_pass *make_pass_branch_prob (gcc::context *ctxt); extern rtl_opt_pass *make_pass_value_profile_transformations (gcc::context *ctxt); +extern rtl_opt_pass *make_pass_postreload_jump (gcc::context *ctxt); extern rtl_opt_pass *make_pass_postreload_cse (gcc::context *ctxt); extern rtl_opt_pass *make_pass_gcse2 (gcc::context *ctxt); extern rtl_opt_pass *make_pass_split_after_reload (gcc::context *ctxt);