Skip to content

Commit 0f73ba4

Browse files
committed
fixed _mm_add_epi8
1 parent 22c505a commit 0f73ba4

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Zend/zend_simd.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ typedef int8x16_t __m128i;
5555
((imm) >= 16 ? vdupq_n_s8(0) : \
5656
vreinterpretq_s8_u8(vextq_u8(vreinterpretq_u8_s8(x), vdupq_n_u8(0), (imm))))
5757

58-
#define _mm_add_epi8(a, b) vaddq_s8(a, b)
58+
/**
59+
* In practice, there is no problem, but a runtime error for signed integer overflow is triggered by UBSAN,
60+
* so perform the calculation as unsigned. Since it is optimized at compile time, there are no unnecessary casts at runtime.
61+
*/
62+
#define _mm_add_epi8(a, b) vreinterpretq_s8_u8(vaddq_u8(vreinterpretq_u8_s8(a), vreinterpretq_u8_s8(b)))
5963

6064
#define _mm_cmpeq_epi8(a, b) (vreinterpretq_s8_u8(vceqq_s8(a, b)))
6165
#define _mm_cmplt_epi8(a, b) (vreinterpretq_s8_u8(vcltq_s8(a, b)))

0 commit comments

Comments
 (0)