From 12fb7712a8a20fce6f3dac80251e67251c01c209 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 14 Mar 2019 20:38:52 +0000 Subject: [PATCH] i386: Handle REG_EH_REGION note When we split: (insn 18 17 76 2 (set (reg:SF 88 [ _19 ]) (float:SF (mem/c:SI (symbol_ref:DI ("d") [flags 0x2] ) [1 d+0 S4 A32]))) "x.ii":4:20 170 {*floatsisf2} (expr_list:REG_EH_REGION (const_int 2 [0x2]) (nil))) to (insn 94 17 18 2 (set (reg:V4SF 115) (vec_merge:V4SF (vec_duplicate:V4SF (float:SF (mem/c:SI (symbol_ref:DI ("d") [flags 0x2] ) [1 d+0 S4 A32]))) (reg:V4SF 114) (const_int 1 [0x1]))) "x.ii":4:20 -1 (nil)) (insn 18 94 76 2 (set (reg:SF 88 [ _19 ]) (subreg:SF (reg:V4SF 115) 0)) "x.ii":4:20 112 {*movsf_internal} (expr_list:REG_EH_REGION (const_int 2 [0x2]) (nil))) we must copy the REG_EH_REGION note to the first insn and split the block after the newly added insn. The REG_EH_REGION on the second insn will be removed later since it no longer traps. gcc/ PR target/89650 * config/i386/i386.c (remove_partial_avx_dependency): Handle REG_EH_REGION note. gcc/testsuite/ PR target/89650 * g++.target/i386/pr89650.C: New test. From-SVN: r269694 --- gcc/ChangeLog | 6 +++++ gcc/config/i386/i386.c | 30 +++++++++++++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.target/i386/pr89650.C | 19 ++++++++++++++++ 4 files changed, 60 insertions(+) create mode 100644 gcc/testsuite/g++.target/i386/pr89650.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index aa4d8ed680d..4890c75c94b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-03-15 H.J. Lu + + PR target/89650 + * config/i386/i386.c (remove_partial_avx_dependency): Handle + REG_EH_REGION note. + 2019-03-14 Martin Liska PR other/89712 diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 783a810437b..70e10119213 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2819,6 +2819,8 @@ remove_partial_avx_dependency (void) rtx set; rtx v4sf_const0 = NULL_RTX; + auto_vec control_flow_insns; + FOR_EACH_BB_FN (bb, cfun) { FOR_BB_INSNS (bb, insn) @@ -2875,6 +2877,17 @@ remove_partial_avx_dependency (void) set_insn = emit_insn_before (set, insn); df_insn_rescan (set_insn); + if (cfun->can_throw_non_call_exceptions) + { + /* Handle REG_EH_REGION note. */ + rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX); + if (note) + { + control_flow_insns.safe_push (set_insn); + add_reg_note (set_insn, REG_EH_REGION, XEXP (note, 0)); + } + } + src = gen_rtx_SUBREG (dest_mode, vec, 0); set = gen_rtx_SET (dest, src); @@ -2925,6 +2938,23 @@ remove_partial_avx_dependency (void) df_insn_rescan (set_insn); df_process_deferred_rescans (); loop_optimizer_finalize (); + + if (!control_flow_insns.is_empty ()) + { + free_dominance_info (CDI_DOMINATORS); + + unsigned int i; + FOR_EACH_VEC_ELT (control_flow_insns, i, insn) + if (control_flow_insn_p (insn)) + { + /* Split the block after insn. There will be a fallthru + edge, which is OK so we keep it. We have to create + the exception edges ourselves. */ + bb = BLOCK_FOR_INSN (insn); + split_block (bb, insn); + rtl_make_eh_edge (NULL, bb, BB_END (bb)); + } + } } bitmap_obstack_release (NULL); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 34f41e5265f..8f7288ed5b2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-03-15 H.J. Lu + + PR target/89650 + * g++.target/i386/pr89650.C: New test. + 2019-03-14 Richard Biener * gcc.dg/gimplefe-13.c: Adjust. diff --git a/gcc/testsuite/g++.target/i386/pr89650.C b/gcc/testsuite/g++.target/i386/pr89650.C new file mode 100644 index 00000000000..4b253cbf467 --- /dev/null +++ b/gcc/testsuite/g++.target/i386/pr89650.C @@ -0,0 +1,19 @@ +// { dg-do compile { target c++11 } } +// { dg-options "-O2 -flive-range-shrinkage -fno-tree-dce -fno-dce -fnon-call-exceptions -mavx" } + +int d, e; +struct g { + float f; + g(float h) : f(h + d) {} + ~g() {} +}; +struct i { + int a; + int b : 4; + int &c; + i(int h) : a(), b(), c(h) {} +}; +int main() { + i j(e); + g k[]{1, 2}; +} -- 2.30.2