aboutsummaryrefslogtreecommitdiff
path: root/libgcc/config
diff options
context:
space:
mode:
authorWolfgang Hospital <Wolfgang.Hospital@arcor.de>2024-05-07 16:24:39 +0200
committerGeorg-Johann Lay <avr@gjlay.de>2024-05-07 16:32:07 +0200
commit8d2c93fcfe1afc5291bbbe162c3b7ad5764f6d8d (patch)
treee40a2309a046c0a556a80a4c5a9bbfd4a787bf81 /libgcc/config
parent3f04f3939ea0ac8fdd766a60655d29de2ffb44e5 (diff)
downloadgcc-8d2c93fcfe1afc5291bbbe162c3b7ad5764f6d8d.zip
gcc-8d2c93fcfe1afc5291bbbe162c3b7ad5764f6d8d.tar.gz
gcc-8d2c93fcfe1afc5291bbbe162c3b7ad5764f6d8d.tar.bz2
AVR: target/114835 - Tweak popcountqi2
libgcc/ PR target/114835 * config/avr/lib1funcs.S (__popcountqi2): Use code that is one instruction shorter / faster.
Diffstat (limited to 'libgcc/config')
-rw-r--r--libgcc/config/avr/lib1funcs.S30
1 files changed, 15 insertions, 15 deletions
diff --git a/libgcc/config/avr/lib1funcs.S b/libgcc/config/avr/lib1funcs.S
index af4d7d9..4ac31fa 100644
--- a/libgcc/config/avr/lib1funcs.S
+++ b/libgcc/config/avr/lib1funcs.S
@@ -3050,21 +3050,21 @@ ENDF __popcountdi2
;; r24 = popcount8 (r24)
;; clobbers: __tmp_reg__
DEFUN __popcountqi2
- mov __tmp_reg__, r24
- andi r24, 1
- lsr __tmp_reg__
- lsr __tmp_reg__
- adc r24, __zero_reg__
- lsr __tmp_reg__
- adc r24, __zero_reg__
- lsr __tmp_reg__
- adc r24, __zero_reg__
- lsr __tmp_reg__
- adc r24, __zero_reg__
- lsr __tmp_reg__
- adc r24, __zero_reg__
- lsr __tmp_reg__
- adc r24, __tmp_reg__
+ mov __tmp_reg__, r24 ; oeoeoeoe
+ andi r24, 0xAA ; o0o0o0o0
+ lsr r24 ; 0o0o0o0o
+ ;; Four values 0, 1 or 2: # bits set o+e
+ sub __tmp_reg__, r24 ; 44332211
+ mov r24, __tmp_reg__ ; 44332211
+ andi r24, 0x33 ; 00330011
+ eor __tmp_reg__, r24 ; 44002200
+ lsr __tmp_reg__ ; 04400220
+ lsr __tmp_reg__ ; 00440022
+ add r24, __tmp_reg__ ; 04210421
+ mov __tmp_reg__, r24 ; h421l421
+ swap __tmp_reg__ ; l421h421
+ add r24, __tmp_reg__ ; 84218421
+ andi r24, 0xf ; 00008421 /17
ret
ENDF __popcountqi2
#endif /* defined (L_popcountqi2) */