File tree 2 files changed +44
-1
lines changed
ext/standard/tests/strings
2 files changed +44
-1
lines changed Original file line number Diff line number Diff line change 35
35
# include <langinfo.h>
36
36
#endif
37
37
38
+ #ifdef ZEND_INTRIN_AVX2_NATIVE
39
+ #include <immintrin.h>
40
+ #endif
38
41
#ifdef __SSE2__
39
42
#include <emmintrin.h>
40
43
#endif
@@ -54,7 +57,30 @@ static _locale_t current_locale = NULL;
54
57
55
58
#define TYPE_PAIR (t1 ,t2 ) (((t1) << 4) | (t2))
56
59
57
- #if __SSE2__
60
+ #ifdef ZEND_INTRIN_AVX2_NATIVE
61
+ #define HAVE_BLOCKCONV
62
+
63
+ #define BLOCKCONV_INIT_RANGE (start , end ) \
64
+ const __m256i blconv_offset = _mm256_set1_epi8((signed char)(SCHAR_MIN - start)); \
65
+ const __m256i blconv_threshold = _mm256_set1_epi8(SCHAR_MIN + (end - start) + 1);
66
+
67
+ #define BLOCKCONV_STRIDE sizeof(__m256i)
68
+
69
+ #define BLOCKCONV_INIT_DELTA (delta ) \
70
+ const __m256i blconv_delta = _mm256_set1_epi8(delta);
71
+
72
+ #define BLOCKCONV_LOAD (input ) \
73
+ __m256i blconv_operand = _mm256_loadu_si256((__m256i*)(input)); \
74
+ __m256i blconv_mask = _mm256_cmpgt_epi8(blconv_threshold, _mm256_add_epi8(blconv_operand, blconv_offset));
75
+
76
+ #define BLOCKCONV_FOUND () _mm256_movemask_epi8(blconv_mask)
77
+
78
+ #define BLOCKCONV_STORE (dest ) \
79
+ __m256i blconv_add = _mm256_and_si256(blconv_mask, blconv_delta); \
80
+ __m256i blconv_result = _mm256_add_epi8(blconv_operand, blconv_add); \
81
+ _mm256_storeu_si256((__m256i*)(dest), blconv_result);
82
+
83
+ #elif __SSE2__
58
84
#define HAVE_BLOCKCONV
59
85
60
86
/* Common code for SSE2 accelerated character case conversion */
Original file line number Diff line number Diff line change @@ -28,6 +28,11 @@ $strings = array (
28
28
"zzzzzzzzzzzzzzzzzzzz " ,
29
29
"```````````````````` " ,
30
30
"{{{{{{{{{{{{{{{{{{{{ " ,
31
+ /* And the AVX2 implementation also */
32
+ "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{ " ,
33
+ "abcdefghijklmnopqrstuvwxyz01234 " ,
34
+ "abcdefghijklmnopqrstuvwxyz012345 " ,
35
+ "abcdefghijklmnopqrstuvwxyz0123456 " ,
31
36
"abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ "
32
37
);
33
38
@@ -348,6 +353,18 @@ string(20) "````````````````````"
348
353
string(20) "{{{{{{{{{{{{{{{{{{{{"
349
354
350
355
-- Iteration 12 --
356
+ string(40) "{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{"
357
+
358
+ -- Iteration 13 --
359
+ string(31) "ABCDEFGHIJKLMNOPQRSTUVWXYZ01234"
360
+
361
+ -- Iteration 14 --
362
+ string(32) "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345"
363
+
364
+ -- Iteration 15 --
365
+ string(33) "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456"
366
+
367
+ -- Iteration 16 --
351
368
string(62) "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
352
369
353
370
*** Testing strtoupper() with two different case strings ***
You can’t perform that action at this time.
0 commit comments