Commit 86529a49 by Richard Guenther Committed by Richard Biener

expmed.c (expand_variable_shift): Rename to ...

2011-05-05  Richard Guenther  <rguenther@suse.de>

	* expmed.c (expand_variable_shift): Rename to ...
	(expand_shift_1): ... this.  Take an expanded shift amount.
	For rotates recurse directly not building trees for the shift amount.
	(expand_variable_shift): Wrap around expand_shift_1.
	(expand_shift): Adjust.

From-SVN: r173428
parent 82357998
2011-05-05 Richard Guenther <rguenther@suse.de>
* expmed.c (expand_variable_shift): Rename to ...
(expand_shift_1): ... this. Take an expanded shift amount.
For rotates recurse directly not building trees for the shift amount.
(expand_variable_shift): Wrap around expand_shift_1.
(expand_shift): Adjust.
2011-05-05 Jakub Jelinek <jakub@redhat.com> 2011-05-05 Jakub Jelinek <jakub@redhat.com>
* gimplify.c (create_tmp_var_raw): Don't call build_type_variant. * gimplify.c (create_tmp_var_raw): Don't call build_type_variant.
......
...@@ -2032,14 +2032,14 @@ expand_dec (rtx target, rtx dec) ...@@ -2032,14 +2032,14 @@ expand_dec (rtx target, rtx dec)
/* Output a shift instruction for expression code CODE, /* Output a shift instruction for expression code CODE,
with SHIFTED being the rtx for the value to shift, with SHIFTED being the rtx for the value to shift,
and AMOUNT the tree for the amount to shift by. and AMOUNT the rtx for the amount to shift by.
Store the result in the rtx TARGET, if that is convenient. Store the result in the rtx TARGET, if that is convenient.
If UNSIGNEDP is nonzero, do a logical shift; otherwise, arithmetic. If UNSIGNEDP is nonzero, do a logical shift; otherwise, arithmetic.
Return the rtx for where the value is. */ Return the rtx for where the value is. */
rtx static rtx
expand_variable_shift (enum tree_code code, enum machine_mode mode, rtx shifted, expand_shift_1 (enum tree_code code, enum machine_mode mode, rtx shifted,
tree amount, rtx target, int unsignedp) rtx amount, rtx target, int unsignedp)
{ {
rtx op1, temp = 0; rtx op1, temp = 0;
int left = (code == LSHIFT_EXPR || code == LROTATE_EXPR); int left = (code == LSHIFT_EXPR || code == LROTATE_EXPR);
...@@ -2053,7 +2053,7 @@ expand_variable_shift (enum tree_code code, enum machine_mode mode, rtx shifted, ...@@ -2053,7 +2053,7 @@ expand_variable_shift (enum tree_code code, enum machine_mode mode, rtx shifted,
int attempt; int attempt;
bool speed = optimize_insn_for_speed_p (); bool speed = optimize_insn_for_speed_p ();
op1 = expand_normal (amount); op1 = amount;
op1_mode = GET_MODE (op1); op1_mode = GET_MODE (op1);
/* Determine whether the shift/rotate amount is a vector, or scalar. If the /* Determine whether the shift/rotate amount is a vector, or scalar. If the
...@@ -2138,25 +2138,22 @@ expand_variable_shift (enum tree_code code, enum machine_mode mode, rtx shifted, ...@@ -2138,25 +2138,22 @@ expand_variable_shift (enum tree_code code, enum machine_mode mode, rtx shifted,
code below. */ code below. */
rtx subtarget = target == shifted ? 0 : target; rtx subtarget = target == shifted ? 0 : target;
tree new_amount, other_amount; rtx new_amount, other_amount;
rtx temp1; rtx temp1;
tree type = TREE_TYPE (amount);
if (GET_MODE (op1) != TYPE_MODE (type) new_amount = op1;
&& GET_MODE (op1) != VOIDmode)
op1 = convert_to_mode (TYPE_MODE (type), op1, 1);
new_amount = make_tree (type, op1);
other_amount other_amount
= fold_build2 (MINUS_EXPR, type, = simplify_gen_binary (MINUS, GET_MODE (op1),
build_int_cst (type, GET_MODE_BITSIZE (mode)), GEN_INT (GET_MODE_BITSIZE (mode)),
new_amount); op1);
shifted = force_reg (mode, shifted); shifted = force_reg (mode, shifted);
temp = expand_variable_shift (left ? LSHIFT_EXPR : RSHIFT_EXPR, temp = expand_shift_1 (left ? LSHIFT_EXPR : RSHIFT_EXPR,
mode, shifted, new_amount, 0, 1); mode, shifted, new_amount, 0, 1);
temp1 = expand_variable_shift (left ? RSHIFT_EXPR : LSHIFT_EXPR, temp1 = expand_shift_1 (left ? RSHIFT_EXPR : LSHIFT_EXPR,
mode, shifted, other_amount, mode, shifted, other_amount,
subtarget, 1); subtarget, 1);
return expand_binop (mode, ior_optab, temp, temp1, target, return expand_binop (mode, ior_optab, temp, temp1, target,
unsignedp, methods); unsignedp, methods);
} }
...@@ -2211,12 +2208,25 @@ rtx ...@@ -2211,12 +2208,25 @@ rtx
expand_shift (enum tree_code code, enum machine_mode mode, rtx shifted, expand_shift (enum tree_code code, enum machine_mode mode, rtx shifted,
int amount, rtx target, int unsignedp) int amount, rtx target, int unsignedp)
{ {
/* ??? With re-writing expand_shift we could avoid going through a return expand_shift_1 (code, mode,
tree for the shift amount and directly do GEN_INT (amount). */ shifted, GEN_INT (amount), target, unsignedp);
return expand_variable_shift (code, mode, shifted, }
build_int_cst (integer_type_node, amount),
target, unsignedp); /* Output a shift instruction for expression code CODE,
with SHIFTED being the rtx for the value to shift,
and AMOUNT the tree for the amount to shift by.
Store the result in the rtx TARGET, if that is convenient.
If UNSIGNEDP is nonzero, do a logical shift; otherwise, arithmetic.
Return the rtx for where the value is. */
rtx
expand_variable_shift (enum tree_code code, enum machine_mode mode, rtx shifted,
tree amount, rtx target, int unsignedp)
{
return expand_shift_1 (code, mode,
shifted, expand_normal (amount), target, unsignedp);
} }
/* Indicates the type of fixup needed after a constant multiplication. /* Indicates the type of fixup needed after a constant multiplication.
BASIC_VARIANT means no fixup is needed, NEGATE_VARIANT means that BASIC_VARIANT means no fixup is needed, NEGATE_VARIANT means that
......
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