[llvm-bugs] [Bug 46053] New: Loop counting top bits set badly vectorized on X86

via llvm-bugs llvm-bugs at lists.llvm.org
Sat May 23 12:24:09 PDT 2020


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

            Bug ID: 46053
           Summary: Loop counting top bits set badly vectorized on X86
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Loop Optimizer
          Assignee: unassignedbugs at nondot.org
          Reporter: nikita.ppv at gmail.com
                CC: llvm-bugs at lists.llvm.org, llvm-dev at redking.me.uk,
                    spatel+llvm at rotateright.com

Originally reported at: https://github.com/rust-lang/rust/issues/72355.

A loop counting the number of bytes with the top bit set:

#include <stddef.h>
#include <stdint.h>

uint64_t count_non_ascii(unsigned *buffer, size_t len) {
    uint64_t count = 0;
    for (size_t i = 0; i < len; i++) {
        count += buffer[i] >= 0x80;
    }
    return count;
}

Gets vectorized to some complicated code: https://c.godbolt.org/z/jTU3rX

While this could be just movmsk + popcnt.

-- 
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/20200523/1d186105/attachment-0001.html>


More information about the llvm-bugs mailing list