-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Open
Labels
Description
Bugzilla Link | 46053 |
Version | trunk |
OS | Linux |
CC | @Dushistov,@efriedma-quic,@fhahn,@hsivonen,@RKSimon,@rotateright |
Extended Description
Originally reported at: rust-lang/rust#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.