public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/114835] New: AVR popcountqi2 is not fast&small as can be
@ 2024-04-24 15:20 WolfgaNg.Hospital at arcor dot de
  0 siblings, 0 replies; only message in thread
From: WolfgaNg.Hospital at arcor dot de @ 2024-04-24 15:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114835

            Bug ID: 114835
           Summary: AVR popcountqi2 is not fast&small as can be
           Product: gcc
           Version: 13.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: WolfgaNg.Hospital at arcor dot de
  Target Milestone: ---

Created attachment 58025
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58025&action=edit
AVR assembly code for __popcountqi2

For 8-bit AVRs, the current 16-instruction __popcountqi2 uses 6 ADC
instructions to establish the number of bits set in a byte.  
In "Bit Twiddling Hacks", Sean E. Anderson presents several approaches to this;
"parallel/sideways addition" can be coded with one instruction&cycle less.

When establishing the "popcount" of an uint8_t, I've seen GCC to widen the
value to "half int" and use __popcountqi2 twice.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-04-24 15:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-24 15:20 [Bug target/114835] New: AVR popcountqi2 is not fast&small as can be WolfgaNg.Hospital at arcor dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).