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.

Reply via email to