Last active
May 19, 2019 14:49
-
-
Save lemire/5212384d74c5f4b6eb762ac238eedc81 to your computer and use it in GitHub Desktop.
Compile this and run it through valgrind 3.13.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// gcc -o t2 t2.c -mavx2 | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdbool.h> | |
#include <x86intrin.h> | |
__attribute__((no_sanitize("memory"))) | |
__attribute__ ((noinline)) | |
bool hash_zero_byte(char *va) { | |
__m256i v = _mm256_loadu_si256((__m256i *) va); | |
__m256i vz = _mm256_cmpeq_epi8(v,_mm256_setzero_si256()); | |
return ! _mm256_testz_si256(vz,vz); | |
} | |
int main() { | |
char buffer[32]; | |
buffer[0] = 'a'; | |
buffer[1] = '\0'; | |
printf("%s\n", buffer); | |
printf("has zero %d \n", hash_zero_byte(buffer)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment