+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
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)
{
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)
{
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 *);
/* 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;
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;
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;
}
}
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));
}
\f
+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
--- /dev/null
+/* 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;
+}