On 3/27/19 9:24 AM, Jeff Law wrote: > On 3/27/19 8:36 AM, Jakub Jelinek wrote: >> On Sun, Mar 24, 2019 at 09:20:07AM -0600, Jeff Law wrote: >>> However, I'm increasingly of the opinion that MIPS targets need to drop >>> off the priority platform list. Given the trajectory I see for MIPS >>> based processors in industry, it's really hard to justify spending this >>> much time on them, particularly for low priority code quality issues. >> >> Besides what has been discussed on IRC for the PR89826 fix, that we really >> need a df_analyze before processing the first block, because otherwise we >> can't rely on the REG_UNUSED notes in the IL, I see some other issues, but I >> admit I don't know much about df nor regcprop. > RIght. I plan to commit that today along with the test reordering you > pointed out. And the actual patch committed after the usual bootstrapping & regression test on x86_64 plus testing on various *-elf platforms, mips64-linux-gnu, mips64el-linux-gnu and others :-)
Jeff
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 07a1333cee0..f8a353d16c0 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,13 @@ +2019-03-27 Jeff Law <l...@redhat.com> + + + PR rtl-optimization/87761 + PR rtl-optimization/89826 + * regcprop.c (copyprop_hardreg_forward_1): Move may_trap_p test + slightly later. + (pass_cprop_hardreg::execute): Call df_analyze after adding the + note problem to get REG_DEAD/REG_UNUSED notes updated. + 2019-03-27 Richard Biener <rguent...@suse.de> PR tree-optimization/89463 diff --git a/gcc/regcprop.c b/gcc/regcprop.c index 8ca523ffe23..3efe21f377c 100644 --- a/gcc/regcprop.c +++ b/gcc/regcprop.c @@ -800,9 +800,9 @@ copyprop_hardreg_forward_1 (basic_block bb, struct value_data *vd) /* Detect obviously dead sets (via REG_UNUSED notes) and remove them. */ if (set - && !may_trap_p (set) && !RTX_FRAME_RELATED_P (insn) && INSN_P (insn) + && !may_trap_p (set) && find_reg_note (insn, REG_UNUSED, SET_DEST (set)) && !side_effects_p (SET_SRC (set)) && !side_effects_p (SET_DEST (set))) @@ -1293,7 +1293,10 @@ pass_cprop_hardreg::execute (function *fun) auto_sbitmap visited (last_basic_block_for_fn (fun)); bitmap_clear (visited); + /* We need accurate notes. Earlier passes such as if-conversion may + leave notes in an inconsistent state. */ df_note_add_problem (); + df_analyze (); /* It is tempting to set DF_LR_RUN_DCE, but DCE may choose to delete an insn and this pass would not have visibility into the removal. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0679cb72e52..b2c649cfb3e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-03-26 Jeff Law <l...@redhat.com> + + PR rtl-optimization/87761 + PR rtl-optimization/89826 + * gcc.c-torture/execute/pr89826.c: New test. + 2019-03-27 Richard Biener <rguent...@suse.de> * gcc.dg/torture/20190327-1.c: New testcase. diff --git a/gcc/testsuite/gcc.c-torture/execute/pr89826.c b/gcc/testsuite/gcc.c-torture/execute/pr89826.c new file mode 100644 index 00000000000..091644849d3 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr89826.c @@ -0,0 +1,21 @@ +typedef unsigned int u32; +typedef unsigned long long u64; +u64 a; +u32 b; + +u64 +foo (u32 d) +{ + a -= d ? 0 : ~a; + return a + b; +} + +int +main (void) +{ + u64 x = foo (2); + if (x != 0) + __builtin_abort(); + return 0; +} +