Commit ae20d760 by Eric Botcazou Committed by Eric Botcazou

re PR rtl-optimization/84071 (wrong elimination of zero-extension after sign-extended load)

	PR rtl-optimization/84071
	* combine.c (record_dead_and_set_regs_1): Record the source unmodified
	for a paradoxical SUBREG on a WORD_REGISTER_OPERATIONS target.

From-SVN: r257224
parent b6fb257b
2018-01-31 Eric Botcazou <ebotcazou@adacore.com>
PR rtl-optimization/84071
* combine.c (record_dead_and_set_regs_1): Record the source unmodified
for a paradoxical SUBREG on a WORD_REGISTER_OPERATIONS target.
2018-01-31 Claudiu Zissulescu <claziss@synopsys.com>
* config/arc/arc.c (arc_handle_aux_attribute): New function.
......
......@@ -13245,18 +13245,25 @@ record_dead_and_set_regs_1 (rtx dest, const_rtx setter, void *data)
if (REG_P (dest))
{
/* If we are setting the whole register, we know its value. Otherwise
show that we don't know the value. We can handle SUBREG in
some cases. */
show that we don't know the value. We can handle a SUBREG if it's
the low part, but we must be careful with paradoxical SUBREGs on
RISC architectures because we cannot strip e.g. an extension around
a load and record the naked load since the RTL middle-end considers
that the upper bits are defined according to LOAD_EXTEND_OP. */
if (GET_CODE (setter) == SET && dest == SET_DEST (setter))
record_value_for_reg (dest, record_dead_insn, SET_SRC (setter));
else if (GET_CODE (setter) == SET
&& GET_CODE (SET_DEST (setter)) == SUBREG
&& SUBREG_REG (SET_DEST (setter)) == dest
&& known_le (GET_MODE_PRECISION (GET_MODE (dest)), BITS_PER_WORD)
&& known_le (GET_MODE_PRECISION (GET_MODE (dest)),
BITS_PER_WORD)
&& subreg_lowpart_p (SET_DEST (setter)))
record_value_for_reg (dest, record_dead_insn,
gen_lowpart (GET_MODE (dest),
SET_SRC (setter)));
WORD_REGISTER_OPERATIONS
&& paradoxical_subreg_p (SET_DEST (setter))
? SET_SRC (setter)
: gen_lowpart (GET_MODE (dest),
SET_SRC (setter)));
else
record_value_for_reg (dest, record_dead_insn, NULL_RTX);
}
......
2018-01-31 Eric Botcazou <ebotcazou@adacore.com>
* gcc.c-torture/execute/20180131-1.c: New test.
2018-01-31 Claudiu Zissulescu <claziss@synopsys.com>
* gcc.target/arc/taux-1.c: New test.
......
/* PR rtl-optimization/84071 */
/* Reported by Wilco <wilco@gcc.gnu.org> */
extern void abort (void);
typedef union
{
signed short ss;
unsigned short us;
int x;
} U;
int f(int x, int y, int z, int a, U u) __attribute__((noclone, noinline));
int f(int x, int y, int z, int a, U u)
{
return (u.ss <= 0) + u.us;
}
int main (void)
{
U u = { .ss = -1 };
if (f (0, 0, 0, 0, u) != (1 << sizeof (short) * 8))
abort ();
return 0;
}
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