Commit 33006d53 by Jakub Jelinek Committed by Jakub Jelinek

re PR rtl-optimization/83723 (ICE: in gen_rtx_SUBREG, at emit-rtl.c:1010)

	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.

	* gcc.dg/pr83723.c: New test.

From-SVN: r257725
parent c9b34e39
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> 2018-02-16 Eric Botcazou <ebotcazou@adacore.com>
PR rtl-optimization/81443 PR rtl-optimization/81443
......
...@@ -5287,7 +5287,8 @@ inherit_reload_reg (bool def_p, int original_regno, ...@@ -5287,7 +5287,8 @@ inherit_reload_reg (bool def_p, int original_regno,
lra_assert (DEBUG_INSN_P (usage_insn)); lra_assert (DEBUG_INSN_P (usage_insn));
next_usage_insns = XEXP (next_usage_insns, 1); 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)); lra_update_insn_regno_info (as_a <rtx_insn *> (usage_insn));
if (lra_dump_file != NULL) if (lra_dump_file != NULL)
{ {
...@@ -5608,7 +5609,8 @@ split_reg (bool before_p, int original_regno, rtx_insn *insn, ...@@ -5608,7 +5609,8 @@ split_reg (bool before_p, int original_regno, rtx_insn *insn,
usage_insn = XEXP (next_usage_insns, 0); usage_insn = XEXP (next_usage_insns, 0);
lra_assert (DEBUG_INSN_P (usage_insn)); lra_assert (DEBUG_INSN_P (usage_insn));
next_usage_insns = XEXP (next_usage_insns, 1); 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)); lra_update_insn_regno_info (as_a <rtx_insn *> (usage_insn));
if (lra_dump_file != NULL) if (lra_dump_file != NULL)
{ {
......
...@@ -309,7 +309,7 @@ extern void lra_update_dups (lra_insn_recog_data_t, signed char *); ...@@ -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 *, extern void lra_process_new_insns (rtx_insn *, rtx_insn *, rtx_insn *,
const char *); 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 bool lra_substitute_pseudo_within_insn (rtx_insn *, int, rtx, bool);
extern lra_insn_recog_data_t lra_set_insn_recog_data (rtx_insn *); 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, ...@@ -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 /* Replace all references to register OLD_REGNO in *LOC with pseudo
register NEW_REG. Try to simplify subreg of constant if SUBREG_P. 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 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; rtx x = *loc;
bool result = false; bool result = false;
...@@ -1931,11 +1933,14 @@ lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p) ...@@ -1931,11 +1933,14 @@ lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p)
if (mode != inner_mode if (mode != inner_mode
&& ! (CONST_INT_P (new_reg) && SCALAR_INT_MODE_P (mode))) && ! (CONST_INT_P (new_reg) && SCALAR_INT_MODE_P (mode)))
{ {
if (!partial_subreg_p (mode, inner_mode) poly_uint64 offset = 0;
|| ! SCALAR_INT_MODE_P (inner_mode)) if (partial_subreg_p (mode, inner_mode)
new_reg = gen_rtx_SUBREG (mode, new_reg, 0); && 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 else
new_reg = gen_lowpart_SUBREG (mode, new_reg); new_reg = gen_rtx_SUBREG (mode, new_reg, offset);
} }
*loc = new_reg; *loc = new_reg;
return true; return true;
...@@ -1948,14 +1953,14 @@ lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p) ...@@ -1948,14 +1953,14 @@ lra_substitute_pseudo (rtx *loc, int old_regno, rtx new_reg, bool subreg_p)
if (fmt[i] == 'e') if (fmt[i] == 'e')
{ {
if (lra_substitute_pseudo (&XEXP (x, i), old_regno, if (lra_substitute_pseudo (&XEXP (x, i), old_regno,
new_reg, subreg_p)) new_reg, subreg_p, debug_p))
result = true; result = true;
} }
else if (fmt[i] == 'E') else if (fmt[i] == 'E')
{ {
for (j = XVECLEN (x, i) - 1; j >= 0; j--) for (j = XVECLEN (x, i) - 1; j >= 0; j--)
if (lra_substitute_pseudo (&XVECEXP (x, i, j), old_regno, if (lra_substitute_pseudo (&XVECEXP (x, i, j), old_regno,
new_reg, subreg_p)) new_reg, subreg_p, debug_p))
result = true; result = true;
} }
} }
...@@ -1970,7 +1975,8 @@ lra_substitute_pseudo_within_insn (rtx_insn *insn, int old_regno, ...@@ -1970,7 +1975,8 @@ lra_substitute_pseudo_within_insn (rtx_insn *insn, int old_regno,
rtx new_reg, bool subreg_p) rtx new_reg, bool subreg_p)
{ {
rtx loc = insn; 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));
} }
......
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> 2018-02-16 Richard Biener <rguenther@suse.de>
PR tree-optimization/84399 PR tree-optimization/84399
......
/* 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;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment