diff options
author | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-10 02:32:19 +0000 |
---|---|---|
committer | sayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4> | 2004-09-10 02:32:19 +0000 |
commit | 93fe66e56cb15ecf7dc174c28675226908d3ca46 (patch) | |
tree | 128d865fb09e434370de0a3bdcbdeb884d7c332d /gcc | |
parent | 6769a8122a9c0bac1d152adc5a18169178b979d7 (diff) | |
download | gcc-93fe66e56cb15ecf7dc174c28675226908d3ca46.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@87271 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/config/i386/i386.c | 24 |
2 files changed, 30 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 06bef510120..90ca63fd3ca 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 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 size, and the low and high parts of a DImode constant are equal, copy one register to another instead of loading the same immediate diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 2a175452a19..e034fa9ef4e 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -9973,6 +9973,26 @@ ix86_split_long_move (rtx operands[]) 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 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); if (count > 32) - emit_insn (gen_ashlsi3 (high[0], high[0], GEN_INT (count - 32))); + ix86_expand_ashlsi3_const (high[0], count - 32); } else { if (!rtx_equal_p (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_ashlsi3 (low[0], low[0], GEN_INT (count))); + ix86_expand_ashlsi3_const (low[0], count); } } else |