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: unassignedb...@nondot.org
          Reporter: nikita....@gmail.com
                CC: llvm-bugs@lists.llvm.org, llvm-...@redking.me.uk,
                    spatel+l...@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to