diff options
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 11 | ||||
-rw-r--r-- | gcc/lra-constraints.c | 6 | ||||
-rw-r--r-- | gcc/lra-int.h | 2 | ||||
-rw-r--r-- | gcc/lra.c | 24 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr83723.c | 20 |
6 files changed, 56 insertions, 12 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 16c9d9b..76eee8a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,14 @@ +2018-02-16 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/83723 + * lra-int.h (lra_substitute_pseudo): Add DEBUG_P argument. + * lra.c (lra_substitute_pseudo): Likewise. If true, use + gen_rtx_raw_SUBREG instead of gen_rtx_SUBREG. Pass DEBUG_P to + recursive calls. + (lra_substitute_pseudo_within_insn): Adjust lra_substitute_pseudo + callers. + * lra-constraints.c (inherit_reload_reg, split_reg): Likewise. + 2018-02-16 Eric Botcazou <ebotcazou@adacore.com> PR rtl-optimization/81443 diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index 125bbb6..9d22da2 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -5287,7 +5287,8 @@ inherit_reload_reg (bool def_p, int original_regno, lra_assert (DEBUG_INSN_P (usage_insn)); next_usage_insns = XEXP (next_usage_insns, 1); } - lra_substitute_pseudo (&usage_insn, original_regno, new_reg, false); + lra_substitute_pseudo (&usage_insn, original_regno, new_reg, false, + DEBUG_INSN_P (usage_insn)); lra_update_insn_regno_info (as_a <rtx_insn *> (usage_insn)); if (lra_dump_file != NULL) { @@ -5608,7 +5609,8 @@ split_reg (bool before_p, int original_regno, rtx_insn *insn, usage_insn = XEXP (next_usage_insns, 0); lra_assert (DEBUG_INSN_P (usage_insn)); next_usage_insns = XEXP (next_usage_insns, 1); - lra_substitute_pseudo (&usage_insn, original_regno, new_reg, false); + lra_substitute_pseudo (&usage_insn, original_regno, new_reg, false, + true); lra_update_insn_regno_info (as_a <rtx_insn *> (usage_insn)); if (lra_dump_file != NULL) { diff --git a/gcc/lra-int.h b/gcc/lra-int.h index d737816..662bc4c 100644 --- a/gcc/lra-int.h +++ b/gcc/lra-int.h @@ -309,7 +309,7 @@ extern void lra_update_dups (lra_insn_recog_data_t, signed char *); extern void lra_process_new_insns (rtx_insn *, rtx_insn *, rtx_insn *, const char *); -extern bool lra_substitute_pseudo (rtx *, int, rtx, bool); +extern bool lra_substitute_pseudo (rtx *, int, rtx, bool, bool); extern bool lra_substitute_pseudo_within_insn (rtx_insn *, int, rtx, bool); extern lra_insn_recog_data_t lra_set_insn_recog_data (rtx_insn *); @@ -1893,9 +1893,11 @@ lra_process_new_insns (rtx_insn *insn, rtx_insn *before, rtx_insn *after, /* Replace all references to register OLD_REGNO in *LOC with pseudo register NEW_REG. Try to simplify subreg of constant if SUBREG_P. - Return true if any change was made. */ + DEBUG_P is if LOC is within a DEBUG_INSN. Return true if any + change was made. */ bool -lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p) +lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p, + bool debug_p) { rtx x = *loc; bool result = false; @@ -1931,11 +1933,14 @@ lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p) if (mode != inner_mode && ! (CONST_INT_P (new_reg) && SCALAR_INT_MODE_P (mode))) { - if (!partial_subreg_p (mode, inner_mode) - || ! SCALAR_INT_MODE_P (inner_mode)) - new_reg = gen_rtx_SUBREG (mode, new_reg, 0); + poly_uint64 offset = 0; + if (partial_subreg_p (mode, inner_mode) + && SCALAR_INT_MODE_P (inner_mode)) + offset = subreg_lowpart_offset (mode, inner_mode); + if (debug_p) + new_reg = gen_rtx_raw_SUBREG (mode, new_reg, offset); else - new_reg = gen_lowpart_SUBREG (mode, new_reg); + new_reg = gen_rtx_SUBREG (mode, new_reg, offset); } *loc = new_reg; return true; @@ -1948,14 +1953,14 @@ lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p) if (fmt[i] == 'e') { if (lra_substitute_pseudo (&XEXP (x, i), old_regno, - new_reg, subreg_p)) + new_reg, subreg_p, debug_p)) result = true; } else if (fmt[i] == 'E') { for (j = XVECLEN (x, i) - 1; j >= 0; j--) if (lra_substitute_pseudo (&XVECEXP (x, i, j), old_regno, - new_reg, subreg_p)) + new_reg, subreg_p, debug_p)) result = true; } } @@ -1970,7 +1975,8 @@ lra_substitute_pseudo_within_insn (rtx_insn *insn, int old_regno, rtx new_reg, bool subreg_p) { rtx loc = insn; - return lra_substitute_pseudo (&loc, old_regno, new_reg, subreg_p); + return lra_substitute_pseudo (&loc, old_regno, new_reg, subreg_p, + DEBUG_INSN_P (insn)); } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 772879f..64d0308 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2018-02-16 Jakub Jelinek <jakub@redhat.com> + + PR rtl-optimization/83723 + * gcc.dg/pr83723.c: New test. + 2018-02-16 Richard Biener <rguenther@suse.de> PR tree-optimization/84399 diff --git a/gcc/testsuite/gcc.dg/pr83723.c b/gcc/testsuite/gcc.dg/pr83723.c new file mode 100644 index 0000000..a64fe9b --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr83723.c @@ -0,0 +1,20 @@ +/* PR rtl-optimization/83723 */ +/* { dg-do compile } */ +/* { dg-options "-g -O2" } */ +/* { dg-additional-options "-mfpmath=sse -msse2" { target i?86-*-* x86_64-*-* } } */ +/* { dg-additional-options "-fpie" { target pie } } */ + +int foo (void); +float bar (float); +int *v; + +void +baz (void) +{ + float a = bar (0.0); + bar (a); + if (v) + bar (1.0); + if (a < 1.0) + a = foo () / a; +} |