Commit 1b83d209 by Roger Sayle Committed by Roger Sayle

i386.c (ix86_expand_ashlsi3_const): New function to expand a left shift by an…

i386.c (ix86_expand_ashlsi3_const): New function to expand a left shift by an immediate constant as either an ashl...


	* config/i386/i386.c (ix86_expand_ashlsi3_const): New function to
	expand a left shift by an immediate constant as either an ashl or
	a sequence of additions.
	(ix86_split_ashldi): Use new ix86_expand_ashlsi3_const function
	instead of calling gen_ashlsi3 with a constant directly.

From-SVN: r87271
parent 903a5059
2004-09-09 Roger Sayle <roger@eyesopen.com> 2004-09-09 Roger Sayle <roger@eyesopen.com>
* config/i386/i386.c (ix86_expand_ashlsi3_const): New function to
expand a left shift by an immediate constant as either an ashl or
a sequence of additions.
(ix86_split_ashldi): Use new ix86_expand_ashlsi3_const function
instead of calling gen_ashlsi3 with a constant directly.
2004-09-09 Roger Sayle <roger@eyesopen.com>
* config/i386/i386.c (ix86_split_long_move): When optimizing for * config/i386/i386.c (ix86_split_long_move): When optimizing for
size, and the low and high parts of a DImode constant are equal, size, and the low and high parts of a DImode constant are equal,
copy one register to another instead of loading the same immediate copy one register to another instead of loading the same immediate
......
...@@ -9973,6 +9973,26 @@ ix86_split_long_move (rtx operands[]) ...@@ -9973,6 +9973,26 @@ ix86_split_long_move (rtx operands[])
return; return;
} }
/* Helper function of ix86_split_ashldi used to generate an SImode
left shift by a constant, either using a single shift or
a sequence of add instructions. */
static void
ix86_expand_ashlsi3_const (rtx operand, int count)
{
if (count == 1)
emit_insn (gen_addsi3 (operand, operand, operand));
else if (!optimize_size
&& count * ix86_cost->add <= ix86_cost->shift_const)
{
int i;
for (i=0; i<count; i++)
emit_insn (gen_addsi3 (operand, operand, operand));
}
else
emit_insn (gen_ashlsi3 (operand, operand, GEN_INT (count)));
}
void void
ix86_split_ashldi (rtx *operands, rtx scratch) ix86_split_ashldi (rtx *operands, rtx scratch)
{ {
...@@ -9990,14 +10010,14 @@ ix86_split_ashldi (rtx *operands, rtx scratch) ...@@ -9990,14 +10010,14 @@ ix86_split_ashldi (rtx *operands, rtx scratch)
emit_move_insn (low[0], const0_rtx); emit_move_insn (low[0], const0_rtx);
if (count > 32) if (count > 32)
emit_insn (gen_ashlsi3 (high[0], high[0], GEN_INT (count - 32))); ix86_expand_ashlsi3_const (high[0], count - 32);
} }
else else
{ {
if (!rtx_equal_p (operands[0], operands[1])) if (!rtx_equal_p (operands[0], operands[1]))
emit_move_insn (operands[0], operands[1]); emit_move_insn (operands[0], operands[1]);
emit_insn (gen_x86_shld_1 (high[0], low[0], GEN_INT (count))); emit_insn (gen_x86_shld_1 (high[0], low[0], GEN_INT (count)));
emit_insn (gen_ashlsi3 (low[0], low[0], GEN_INT (count))); ix86_expand_ashlsi3_const (low[0], count);
} }
} }
else else
......
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