[llvm-bugs] [Bug 50795] New: [SIMD] __builtin_popcount in loop with 8-bit type should generate i8x16.popcnt

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 21 20:52:25 PDT 2021


https://bugs.llvm.org/show_bug.cgi?id=50795

            Bug ID: 50795
           Summary: [SIMD] __builtin_popcount in loop with 8-bit type
                    should generate i8x16.popcnt
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Backend: WebAssembly
          Assignee: unassignedbugs at nondot.org
          Reporter: clang at evan.coeusgroup.com
                CC: llvm-bugs at lists.llvm.org

This *may* be the same issue as #50247, but I suspect it's a bit more
complicated since `__builtin_popcount` takes a 32-bit integer.  Unfortunately
there is no __builtin_popcountb, though :(

If you loop through a vector of bytes and call __builtin_popcount (with
appropriate casts) it would be great if LLVM could just generate an
i8x16.popcnt instead of the mess it currently outputs.  Quick example (or on
Compiler Explorer if you prefer: https://godbolt.org/z/sPMe4na66)



#include <wasm_simd128.h>

#pragma clang diagnostic ignored "-Wmissing-prototypes"

typedef int8_t i8x16 __attribute__((__vector_size__(16)));

i8x16 popcnt(i8x16 a) {
    i8x16 r;

    for (int i = 0 ; i < 16 ; i++) {
        r[i] = (int8_t) __builtin_popcount((unsigned int) a[i]);
    }

    // False positive.  Happens for the math functions, too... very annoying
    #pragma clang diagnostic ignored "-Wconditional-uninitialized"
    return r;
}

i8x16 popcnt_intrin(i8x16 a) {
    return __builtin_wasm_popcnt_i8x16(a);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20210622/09250d87/attachment.html>


More information about the llvm-bugs mailing list