diff --git a/reference/StreamGetSzPtr/StreamGetSzPtr.cpp b/reference/StreamGetSzPtr/StreamGetSzPtr.cpp index 5a32a6577..7032c50cd 100644 --- a/reference/StreamGetSzPtr/StreamGetSzPtr.cpp +++ b/reference/StreamGetSzPtr/StreamGetSzPtr.cpp @@ -31,7 +31,6 @@ int CountLinesOptimized(Stream& s) } } -#ifdef CPU_SIMD int CountLinesOptimizedSIMD(Stream& s) { int n = 0; @@ -40,19 +39,8 @@ int CountLinesOptimizedSIMD(Stream& s) int sz; const byte* p = s.GetSzPtr(sz); - if (sz) { - const byte* e = p + sz; - const byte* e16 = p + (sz & ~15); // Process in 16-byte chunks - i8x16 q = i8all('\n'); - while(p < e16) { - n += CountTrue(i8x16(p) == q); - p += 16; - } - - while (p < e) { // Process remaining bytes (less than 16) - n += (*p++ == '\n'); - } - } + if(sz) + n += memcnt8(p, '\n', sz); // this is using SIMD.. else { int c = s.Get(); if(c < 0) @@ -61,7 +49,6 @@ int CountLinesOptimizedSIMD(Stream& s) } } } -#endif CONSOLE_APP_MAIN { @@ -85,11 +72,9 @@ CONSOLE_APP_MAIN RDUMP(CountLinesOptimized(in)); } -#ifdef CPU_SIMD { - RTIMESTOP("Optimized SIMD"); + RTIMESTOP("Optimized SIMD (using memcnt8)"); FileIn in(arg[0]); RDUMP(CountLinesOptimizedSIMD(in)); } -#endif } diff --git a/uppsrc/Core/Mem.h b/uppsrc/Core/Mem.h index cc92836c9..2f126a35f 100644 --- a/uppsrc/Core/Mem.h +++ b/uppsrc/Core/Mem.h @@ -783,7 +783,7 @@ size_t memcnt16(const void *s, dword value, size_t sz) } #endif - while(p < e) // Process remaining bytes (less than 16) + while(p < e) // Process remaining words (less than 8) n += (*p++ == value); return n; } @@ -807,7 +807,7 @@ size_t memcnt32(const void *s, dword value, size_t sz) } #endif - while(p < e) // Process remaining bytes (less than 16) + while(p < e) // Process remaining dwords (less than 4) n += (*p++ == value); return n; }