Commit e3be1116 by Roger Sayle Committed by Roger Sayle

expr.c (expand_expr <PLUS_EXPR>): Let expand_operands call safe_from_p for us,…

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
parent 69efc31d
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> 2003-10-11 Eric Botcazou <ebotcazou@libertysurf.fr>
PR optimization/12544 PR optimization/12544
......
...@@ -7775,9 +7775,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode, ...@@ -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 /* No sense saving up arithmetic to be done
if it's all in the wrong mode to form part of an address. 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 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, ...@@ -7885,9 +7882,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
TYPE_MODE (TREE_TYPE (exp1)))); TYPE_MODE (TREE_TYPE (exp1))));
} }
if (! safe_from_p (subtarget, TREE_OPERAND (exp, 1), 1))
subtarget = 0;
if (modifier == EXPAND_STACK_PARM) if (modifier == EXPAND_STACK_PARM)
target = 0; target = 0;
...@@ -8066,7 +8060,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode, ...@@ -8066,7 +8060,6 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
target = original_target; target = original_target;
if (target == 0 if (target == 0
|| modifier == EXPAND_STACK_PARM || modifier == EXPAND_STACK_PARM
|| ! safe_from_p (target, TREE_OPERAND (exp, 1), 1)
|| (GET_CODE (target) == MEM && MEM_VOLATILE_P (target)) || (GET_CODE (target) == MEM && MEM_VOLATILE_P (target))
|| GET_MODE (target) != mode || GET_MODE (target) != mode
|| (GET_CODE (target) == REG || (GET_CODE (target) == REG
...@@ -8093,6 +8086,14 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode, ...@@ -8093,6 +8086,14 @@ expand_expr (tree exp, rtx target, enum machine_mode tmode,
if (GET_CODE (target) == MEM) if (GET_CODE (target) == MEM)
target = gen_reg_rtx (mode); 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) if (target != op0)
emit_move_insn (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) ...@@ -9589,8 +9590,7 @@ do_store_flag (tree exp, rtx target, enum machine_mode mode, int only_cheap)
} }
if (! get_subtarget (target) if (! get_subtarget (target)
|| GET_MODE (subtarget) != operand_mode || GET_MODE (subtarget) != operand_mode)
|| ! safe_from_p (subtarget, arg1, 1))
subtarget = 0; subtarget = 0;
expand_operands (arg0, arg1, subtarget, &op0, &op1, 0); expand_operands (arg0, arg1, subtarget, &op0, &op1, 0);
......
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> 2003-10-11 Eric Botcazou <ebotcazou@libertysurf.fr>
* gcc.c-torture/compile/20031011-1.c: New test. * gcc.c-torture/compile/20031011-1.c: New test.
......
/* 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;
}
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