From: Thomas Preud'homme Date: Wed, 7 Dec 2016 17:56:53 +0000 (+0000) Subject: re PR rtl-optimization/78617 (LRA clobbers live register during rematerialization) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8e1d640fcdf694fe1d83818b123b550e0da96705;p=gcc.git re PR rtl-optimization/78617 (LRA clobbers live register during rematerialization) 2016-12-07 Thomas Preud'homme gcc/ PR rtl-optimization/78617 * lra-remat.c (do_remat): Initialize live_hard_regs from live in registers, also setting hard registers mapped to pseudo registers. gcc/testsuite/ PR rtl-optimization/78617 * gcc.c-torture/execute/pr78617.c: New test. From-SVN: r243374 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 1cf31bc3b4b..489ec77e81d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2016-12-07 Thomas Preud'homme + + PR rtl-optimization/78617 + * lra-remat.c (do_remat): Initialize live_hard_regs from live in + registers, also setting hard registers mapped to pseudo registers. + 2016-12-07 David Malcolm * cfgexpand.c (pass_expand::execute): Move stack initializations diff --git a/gcc/lra-remat.c b/gcc/lra-remat.c index f01c6644c42..cdd7057f602 100644 --- a/gcc/lra-remat.c +++ b/gcc/lra-remat.c @@ -1047,6 +1047,7 @@ update_scratch_ops (rtx_insn *remat_insn) static bool do_remat (void) { + unsigned regno; rtx_insn *insn; basic_block bb; bitmap_head avail_cands; @@ -1054,12 +1055,21 @@ do_remat (void) bool changed_p = false; /* Living hard regs and hard registers of living pseudos. */ HARD_REG_SET live_hard_regs; + bitmap_iterator bi; bitmap_initialize (&avail_cands, ®_obstack); bitmap_initialize (&active_cands, ®_obstack); FOR_EACH_BB_FN (bb, cfun) { - REG_SET_TO_HARD_REG_SET (live_hard_regs, df_get_live_out (bb)); + CLEAR_HARD_REG_SET (live_hard_regs); + EXECUTE_IF_SET_IN_BITMAP (df_get_live_in (bb), 0, regno, bi) + { + int hard_regno = regno < FIRST_PSEUDO_REGISTER + ? regno + : reg_renumber[regno]; + if (hard_regno >= 0) + SET_HARD_REG_BIT (live_hard_regs, hard_regno); + } bitmap_and (&avail_cands, &get_remat_bb_data (bb)->avin_cands, &get_remat_bb_data (bb)->livein_cands); /* Activating insns are always in the same block as their corresponding diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 6153fe74d2d..71bf5066269 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-12-07 Thomas Preud'homme + + PR rtl-optimization/78617 + * gcc.c-torture/execute/pr78617.c: New test. + 2016-12-07 Carl Love * gcc.target/powerpc/builtins-3.c: Move built-in tests for P8 and diff --git a/gcc/testsuite/gcc.c-torture/execute/pr78617.c b/gcc/testsuite/gcc.c-torture/execute/pr78617.c new file mode 100644 index 00000000000..89c4f6dea8c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr78617.c @@ -0,0 +1,25 @@ +int a = 0; +int d = 1; +int f = 1; + +int fn1() { + return a || 1 >> a; +} + +int fn2(int p1, int p2) { + return p2 >= 2 ? p1 : p1 >> 1; +} + +int fn3(int p1) { + return d ^ p1; +} + +int fn4(int p1, int p2) { + return fn3(!d > fn2((f = fn1() - 1000) || p2, p1)); +} + +int main() { + if (fn4(0, 0) != 1) + __builtin_abort (); + return 0; +}