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

            Bug ID: 114975
           Summary: [AVR] Using popcounthi2 for 8-bit values despit
                    popcountqi2
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gjl at gcc dot gnu.org
  Target Milestone: ---

C test case

typedef __UINT8_TYPE__ uint8_t;

uint8_t use_pop (uint8_t x)
{
    return __builtin_popcount (x);
}

compiles with

$ avr-gcc pop.c -Os -S

to:

use_pop:
        ldi r25,0
        rcall __popcounthi2
        ret

        .ident  "GCC: (GNU) 14.0.1 20240421 (experimental)"

despite libgcc providing __popcountqi2.

I am not even sure which component is supposed to treat this.  The tree
optimizers do only __builtin_popcount, and as there's nothing like popcount_u8
they cannot do anything about it.  So blaming the middle-end for now.

Reply via email to