diff options
author | Kazu Hirata <kazu@hxi.com> | 2000-07-17 08:55:51 +0000 |
---|---|---|
committer | Jeff Law <law@gcc.gnu.org> | 2000-07-17 02:55:51 -0600 |
commit | 997e5af8289da28a22a0d4a8aafcda9b83b89bd1 (patch) | |
tree | c556a271670640935ae2ffd8815f447da0bec9d7 | |
parent | 3b15076f3646f5421c5476264b2534182553e8aa (diff) | |
download | gcc-997e5af8289da28a22a0d4a8aafcda9b83b89bd1.zip gcc-997e5af8289da28a22a0d4a8aafcda9b83b89bd1.tar.gz gcc-997e5af8289da28a22a0d4a8aafcda9b83b89bd1.tar.bz2 |
h8300.c (two_insn_adds_subs_operand): Improve code for detecting profitable adds/subs sequences.
* h8300.c (two_insn_adds_subs_operand): Improve code for detecting
profitable adds/subs sequences.
From-SVN: r35081
-rw-r--r-- | gcc/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/config/h8300/h8300.c | 33 |
2 files changed, 30 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0d81edd..1e3ac96 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -29,6 +29,9 @@ Mon Jul 17 02:37:06 2000 Marc Espie <espie@openbsd.org> 2000-07-17 Kazu Hirata <kazu@hxi.com> + * h8300.c (two_insn_adds_subs_operand): Improve code for detecting + profitable adds/subs sequences. + * fold-const.c: Fix comment typos. 2000-07-16 Laurynas Biveinis <lauras@softhome.net> diff --git a/gcc/config/h8300/h8300.c b/gcc/config/h8300/h8300.c index 4eb304e..ba46d04 100644 --- a/gcc/config/h8300/h8300.c +++ b/gcc/config/h8300/h8300.c @@ -626,25 +626,46 @@ call_insn_operand (op, mode) return 0; } +/* Return 1 if a addition/subtraction of a constant integer can be + transformed into two consecutive adds/subs that are faster than the + straightforward way. Otherwise, return 0. */ + int two_insn_adds_subs_operand (op, mode) rtx op; - enum machine_mode mode ATTRIBUTE_UNUSED; + enum machine_mode mode; { if (GET_CODE (op) == CONST_INT) { HOST_WIDE_INT value = INTVAL (op); + /* Force VALUE to be positive so that we do not have to consider + the negative case. */ + if (value < 0) + value = -value; if (TARGET_H8300H || TARGET_H8300S) { - if (value >= -8 && value < -4 && value != -7) - return 1; - if (value > 4 && value <= 8 && value != 7) - return 1; + /* A constant addition/subtraction takes 2 states in QImode, + 4 states in HImode, and 6 states in SImode. Thus, the + only case we can win is when SImode is used, in which + case, two adds/subs is used, taking 4 states. */ + if (mode == SImode + && (value == 2 + 1 + || value == 4 + 1 + || value == 4 + 2 + || value == 4 + 4)) + return 1; } else { - if (value == -4 || value == -3 || value == 3 || value == 4) + /* A constant addition/subtraction takes 2 states in + QImode. It takes 6 states in HImode, requiring the + constant to be loaded to a register first, and a lot more + in SImode. Thus the only case we can win is when either + HImode or SImode is used. */ + if (mode != QImode + && (value == 2 + 1 + || value == 2 + 2)) return 1; } } |