Skip to content

Commit 4d80ffd

Browse files
committed
Fix failure of AVX2-accelerated mb_check_encoding on 32-bit MS Windows
1 parent e447036 commit 4d80ffd

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

ext/mbstring/mbstring.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5155,7 +5155,12 @@ static bool mb_fast_check_utf8_avx2(zend_string *str)
51555155
goto check_operand;
51565156
case 7:
51575157
case 8:
5158-
operand = _mm256_set_epi64x(0, 0, 0, *((int64_t*)p));
5158+
/* This was originally: operand = _mm256_set_epi64x(0, 0, 0, *((int64_t*)p));
5159+
* However, it was found that caused test failures on 32-bit MS Windows
5160+
* (Bad 7/8-byte UTF-8 strings would be wrongly passed through as 'valid')
5161+
* It is not clear whether the root cause is a problem with MS Visual C++'s handling
5162+
* of AVX2 intrinsics when building 32-bit binaries, or something else */
5163+
operand = _mm256_set_epi32(0, 0, 0, 0, 0, 0, ((int32_t*)p)[1], ((int32_t*)p)[0]);
51595164
goto check_operand;
51605165
case 9:
51615166
operand = _mm256_set_m128i(_mm_setzero_si128(), _mm_srli_si128(_mm_loadu_si128((__m128i*)(p - 6)), 6));

ext/mbstring/tests/utf_encodings.phpt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ mbstring
55
--SKIPIF--
66
<?php
77
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
8-
if (substr(PHP_OS, 0, 3) === 'WIN' && PHP_INT_SIZE === 4) die("skip not for Windows x86");
98
?>
109
--FILE--
1110
<?php

0 commit comments

Comments
 (0)