Intel Intrinsics Comparing Two Strings

287 Views Asked by At

I am attempting to build a header parser with fast processing. I have two issues, one is that there is a bug in the code below.

void parse_with_simd(const char *buffer, const int buffer_len) {
  const char * value = "GET ";
  __m128i u_str = _mm_loadu_si128((const __m128i *)value);
  __m128i loaded = _mm_loadu_si128((const __m128i *)buffer);
  int not_equal = _mm_cmpestrc(loaded, 4, u_str, 4,
                               _SIDD_UBYTE_OPS | _SIDD_CMP_EQUAL_EACH);
  debug_print("has value %d\n", not_equal);

This is what I have, debug_print is outputting that not_equal = 1.

Here is my test case.

#include "../src/header/header.h"

int main() {
  parse_with_simd("GET / HTTP/1.1", 14);
  parse_with_simd("OPTIONS /",9);
}

Both strings show that the not_equal is 1.

0

There are 0 best solutions below