diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2011-09-26 16:55:55 +0000 |
---|---|---|
committer | Georg-Johann Lay <gjl@gcc.gnu.org> | 2011-09-26 16:55:55 +0000 |
commit | 31fd727b4d33fd4c9814e7796e5770e7643dc7c4 (patch) | |
tree | ad670ff51ebf5ff4c9ec7d3085c0c7cbd8ef69fa /gcc | |
parent | 2186081438d522d8266dae13e9640447b7ad6189 (diff) | |
download | gcc-31fd727b4d33fd4c9814e7796e5770e7643dc7c4.zip gcc-31fd727b4d33fd4c9814e7796e5770e7643dc7c4.tar.gz gcc-31fd727b4d33fd4c9814e7796e5770e7643dc7c4.tar.bz2 |
avr.md (peephole casesi+2): Use -1 instead of 65536.
* config/avr/avr.md (peephole casesi+2): Use -1 instead of 65536.
* config/avr/avr.c (avr_out_compare): Print shorter sequence for
EQ/NE comparisons against +/-1 in the case of unused-after,
non-ld-regs target.
From-SVN: r179206
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/config/avr/avr.c | 31 | ||||
-rw-r--r-- | gcc/config/avr/avr.md | 2 |
3 files changed, 39 insertions, 1 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 49e56ed..71a8d88 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2011-09-26 Georg-Johann Lay <avr@gjlay.de> + + * config/avr/avr.md (peephole casesi+2): Use -1 instead of 65536. + * config/avr/avr.c (avr_out_compare): Print shorter sequence for + EQ/NE comparisons against +/-1 in the case of unused-after, + non-ld-regs target. + 2011-09-26 Jakub Jelinek <jakub@redhat.com> * gimple-fold.c (gimplify_and_update_call_from_tree): Set diff --git a/gcc/config/avr/avr.c b/gcc/config/avr/avr.c index da53041..8675845 100644 --- a/gcc/config/avr/avr.c +++ b/gcc/config/avr/avr.c @@ -3048,6 +3048,37 @@ avr_out_compare (rtx insn, rtx *xop, int *plen) if (plen) *plen = 0; + /* Comparisons == +/-1 and != +/-1 can be done similar to camparing + against 0 by ORing the bytes. This is one instruction shorter. */ + + if (!test_hard_reg_class (LD_REGS, xreg) + && compare_eq_p (insn) + && reg_unused_after (insn, xreg)) + { + if (xval == const1_rtx) + { + avr_asm_len ("dec %A0" CR_TAB + "or %A0,%B0", xop, plen, 2); + + if (n_bytes == 4) + avr_asm_len ("or %A0,%C0" CR_TAB + "or %A0,%D0", xop, plen, 2); + + return ""; + } + else if (xval == constm1_rtx) + { + if (n_bytes == 4) + avr_asm_len ("and %A0,%D0" CR_TAB + "and %A0,%C0", xop, plen, 2); + + avr_asm_len ("and %A0,%B0" CR_TAB + "com %A0", xop, plen, 2); + + return ""; + } + } + for (i = 0; i < n_bytes; i++) { /* We compare byte-wise. */ diff --git a/gcc/config/avr/avr.md b/gcc/config/avr/avr.md index 2efb0c4..790f696 100644 --- a/gcc/config/avr/avr.md +++ b/gcc/config/avr/avr.md @@ -4119,7 +4119,7 @@ (parallel [(set (cc0) (compare (match_dup 0) - (const_int 65535))) + (const_int -1))) (clobber (match_operand:QI 1 "d_register_operand" ""))]) (set (pc) (if_then_else (ne (cc0) (const_int 0)) |