Skip to content

Commit 462fd4d

Browse files
Small change SIMD codes (#18626)
* use zend_simd.h in zend_accelerator_util_funcs.c * use zend_simd.h in mbstring * Remove unnecessary SSE3 includes
1 parent 04522cd commit 462fd4d

File tree

2 files changed

+6
-16
lines changed

2 files changed

+6
-16
lines changed

ext/mbstring/mbstring.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,7 @@
6565

6666
#include "rare_cp_bitvec.h"
6767

68-
#ifdef __SSE2__
69-
#include <emmintrin.h>
70-
#endif
71-
72-
#ifdef __SSE3__
73-
#include <immintrin.h>
74-
#include <pmmintrin.h>
75-
#endif
68+
#include "zend_simd.h"
7669

7770
/* }}} */
7871

@@ -1749,7 +1742,7 @@ PHP_FUNCTION(mb_str_split)
17491742
}
17501743
}
17511744

1752-
#ifdef __SSE2__
1745+
#ifdef XSSE2
17531746
/* Thanks to StackOverflow user 'Paul R' (https://stackoverflow.com/users/253056/paul-r)
17541747
* From: https://stackoverflow.com/questions/36998538/fastest-way-to-horizontally-sum-sse-unsigned-byte-vector
17551748
* Takes a 128-bit XMM register, treats each byte as an 8-bit integer, and sums up all
@@ -1780,7 +1773,7 @@ static size_t mb_fast_strlen_utf8(unsigned char *p, size_t len)
17801773
{
17811774
unsigned char *e = p + len;
17821775

1783-
#ifdef __SSE2__
1776+
#ifdef XSSE2
17841777
if (len >= sizeof(__m128i)) {
17851778
e -= sizeof(__m128i);
17861779

@@ -4919,7 +4912,7 @@ MBSTRING_API bool php_mb_check_encoding(const char *input, size_t length, const
49194912
static bool mb_fast_check_utf8_default(zend_string *str)
49204913
{
49214914
unsigned char *p = (unsigned char*)ZSTR_VAL(str);
4922-
# ifdef __SSE2__
4915+
# ifdef XSSE2
49234916
/* `e` points 1 byte past the last full 16-byte block of string content
49244917
* Note that we include the terminating null byte which is included in each zend_string
49254918
* as part of the content to check; this ensures that multi-byte characters which are

ext/opcache/zend_accelerator_util_funcs.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,7 @@
2727
#include "zend_shared_alloc.h"
2828
#include "zend_observer.h"
2929

30-
#ifdef __SSE2__
31-
/* For SSE2 adler32 */
32-
#include <immintrin.h>
33-
#endif
30+
#include "zend_simd.h"
3431

3532
typedef int (*id_function_t)(void *, void *);
3633
typedef void (*unique_copy_ctor_func_t)(void *pElement);
@@ -466,7 +463,7 @@ static zend_always_inline void adler32_do16_loop(unsigned char *buf, unsigned ch
466463
unsigned int s1 = *s1_out;
467464
unsigned int s2 = *s2_out;
468465

469-
#ifdef __SSE2__
466+
#ifdef XSSE2
470467
const __m128i zero = _mm_setzero_si128();
471468

472469
__m128i accumulate_s2 = zero;

0 commit comments

Comments
 (0)