expr.c (expand_expr <PLUS_EXPR>): Let expand_operands call safe_from_p for us, once it chooses an evaluation order.

* expr.c (expand_expr <PLUS_EXPR>): Let expand_operands call
	safe_from_p for us, once it chooses an evaluation order.
	(expand_expr <MULT_EXPR>): Likewise.
	(expand_expr <MIN_EXPR> <MAX_EXPR>): Likewise.  If expand_operands
	places the second operand in "target", swap the operands.
	(do_store_flag): Let expand_operands call safe_from_p for us.

	* gcc.c-torture/execute/20031011-1.c: New testcase.

From-SVN: r72376
This commit is contained in:
Roger Sayle 2003-10-11 21:00:51 +00:00 committed by Roger Sayle
parent 69efc31da2
commit e3be111613
4 changed files with 53 additions and 9 deletions

View File

@ -1,3 +1,12 @@
2003-10-11 Roger Sayle <roger@eyesopen.com>
* expr.c (expand_expr <PLUS_EXPR>): Let expand_operands call
safe_from_p for us, once it chooses an evaluation order.
(expand_expr <MULT_EXPR>): Likewise.
(expand_expr <MIN_EXPR> <MAX_EXPR>): Likewise. If expand_operands
places the second operand in "target", swap the operands.
(do_store_flag): Let expand_operands call safe_from_p for us.
2003-10-11 Eric Botcazou <ebotcazou@libertysurf.fr>
PR optimization/12544

View File

@ -7775,9 +7775,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
}
}
if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1), 1))
subtarget = 0;
/* No sense saving up arithmetic to be done
if it's all in the wrong mode to form part of an address.
And force_operand won't know whether to sign-extend or
@ -7885,9 +7882,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
TYPE_MODE (TREE_TYPE (exp1))));
}
if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1), 1))
subtarget = 0;
if (modifier == EXPAND_STACK_PARM)
target = 0;
@ -8066,7 +8060,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
target = original_target;
if (target == 0
|| modifier == EXPAND_STACK_PARM
|| ! safe_from_p (target, TREE_OPERAND (exp, 1), 1)
|| (GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
|| GET_MODE (target) != mode
|| (GET_CODE (target) == REG
@ -8093,6 +8086,14 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
if (GET_CODE (target) == MEM)
target = gen_reg_rtx (mode);
/* If op1 was placed in target, swap op0 and op1. */
if (target != op0 && target == op1)
{
rtx tem = op0;
op0 = op1;
op1 = tem;
}
if (target != op0)
emit_move_insn (target, op0);
@ -9589,8 +9590,7 @@ do_store_flag (tree exp, rtx target, enum machine_mode mode, int only_cheap)
}
if (! get_subtarget (target)
|| GET_MODE (subtarget) != operand_mode
|| ! safe_from_p (subtarget, arg1, 1))
|| GET_MODE (subtarget) != operand_mode)
subtarget = 0;
expand_operands (arg0, arg1, subtarget, &op0, &op1, 0);

View File

@ -1,3 +1,7 @@
2003-10-11 Roger Sayle <roger@eyesopen.com>
* gcc.c-torture/execute/20031011-1.c: New testcase.
2003-10-11 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.c-torture/compile/20031011-1.c: New test.

View File

@ -0,0 +1,31 @@
/* Check that MAX_EXPR and MIN_EXPR are working properly. */
#define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
#define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
extern void abort (void);
int main()
{
int ll_bitsize, ll_bitpos;
int rl_bitsize, rl_bitpos;
int end_bit;
ll_bitpos = 32; ll_bitsize = 32;
rl_bitpos = 0; rl_bitsize = 32;
end_bit = MAX (ll_bitpos + ll_bitsize, rl_bitpos + rl_bitsize);
if (end_bit != 64)
abort ();
end_bit = MAX (rl_bitpos + rl_bitsize, ll_bitpos + ll_bitsize);
if (end_bit != 64)
abort ();
end_bit = MIN (ll_bitpos + ll_bitsize, rl_bitpos + rl_bitsize);
if (end_bit != 32)
abort ();
end_bit = MIN (rl_bitpos + rl_bitsize, ll_bitpos + ll_bitsize);
if (end_bit != 32)
abort ();
return 0;
}