Created
September 26, 2011 09:59
Using packed string compare from SSE4.2 to search for certain characters
This file contains hidden or 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
#include <smmintrin.h> | |
typedef union __attribute__((aligned(16))) { | |
unsigned char bytes[16]; | |
__m128i vec; | |
} vec_bytes_128; | |
int main() { | |
int length = 3; | |
vec_bytes_128 in = { 'a', 'e', 'e', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; | |
vec_bytes_128 test = { '\t', '\n', '\\', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | |
int skippable = _mm_cmpistri(test.vec, in.vec, 0); | |
if (skippable > length) | |
skippable = length; | |
exit(skippable); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment