[LLVMbugs] [Bug 14392] New: Multiple consecutive __builtin_popcount()'s may be combined to a bigger type

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Nov 20 11:31:49 PST 2012


             Bug #: 14392
           Summary: Multiple consecutive __builtin_popcount()'s may be
                    combined to a bigger type
           Product: libraries
           Version: trunk
          Platform: PC
        OS/Version: FreeBSD
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Common Code Generator Code
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: jkim at FreeBSD.org
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

Please consider the following example:

% cat popcount.c
popcount(unsigned long x)
        unsigned *p;
        int c, i;

        for (c = i = 0, p = (void *)&x; i < sizeof(x) / sizeof(*p); i++)
                c += __builtin_popcount(*p++);
        return (c);
% clang -O2 -mpopcnt -S popcount.c
% cat popcount.s
        .file   "popcount.c"
        .globl  popcount
        .align  16, 0x90
        .type   popcount, at function
popcount:                               # @popcount
# BB#0:                                 # %entry
        popcntl %edi, %ecx
        shrq    $32, %rdi
        popcntl %edi, %eax
        addl    %ecx, %eax
        .size   popcount, .Ltmp0-popcount

        .section        ".note.GNU-stack","", at progbits

Ideally, it should be folded into "return (__builtin_popcountl(x));" and
generate "popcntq %rdi, %rax; ret".

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list