Commit 68301c0df82 for php
commit 68301c0df82c31a1e1f8edac42123695f0850033
Author: Weilin Du <weilindu@php.net>
Date: Wed Sep 30 00:02:36 2026 +0800
ext/standard: Remove redundant if-branch in rot13 (#23795)
diff --git a/UPGRADING b/UPGRADING
index 27dc06f12d2..10994928470 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -84,3 +84,4 @@ PHP 8.7 UPGRADE NOTES
- Standard:
. Improved performance of array_splice() when inserting without removing
elements.
+ . Improved performance of str_rot13().
diff --git a/ext/standard/string.c b/ext/standard/string.c
index ddd3f31bf14..d23c117321a 100644
--- a/ext/standard/string.c
+++ b/ext/standard/string.c
@@ -6054,34 +6054,26 @@ static zend_string *php_str_rot13(zend_string *str)
gt = _mm_cmpgt_epi8(in, a_minus_1);
lt = _mm_cmplt_epi8(in, m_plus_1);
cmp = _mm_and_si128(lt, gt);
- if (_mm_movemask_epi8(cmp)) {
- cmp = _mm_and_si128(cmp, add);
- delta = _mm_or_si128(delta, cmp);
- }
+ cmp = _mm_and_si128(cmp, add);
+ delta = _mm_or_si128(delta, cmp);
gt = _mm_cmpgt_epi8(in, n_minus_1);
lt = _mm_cmplt_epi8(in, z_plus_1);
cmp = _mm_and_si128(lt, gt);
- if (_mm_movemask_epi8(cmp)) {
- cmp = _mm_and_si128(cmp, sub);
- delta = _mm_or_si128(delta, cmp);
- }
+ cmp = _mm_and_si128(cmp, sub);
+ delta = _mm_or_si128(delta, cmp);
gt = _mm_cmpgt_epi8(in, A_minus_1);
lt = _mm_cmplt_epi8(in, M_plus_1);
cmp = _mm_and_si128(lt, gt);
- if (_mm_movemask_epi8(cmp)) {
- cmp = _mm_and_si128(cmp, add);
- delta = _mm_or_si128(delta, cmp);
- }
+ cmp = _mm_and_si128(cmp, add);
+ delta = _mm_or_si128(delta, cmp);
gt = _mm_cmpgt_epi8(in, N_minus_1);
lt = _mm_cmplt_epi8(in, Z_plus_1);
cmp = _mm_and_si128(lt, gt);
- if (_mm_movemask_epi8(cmp)) {
- cmp = _mm_and_si128(cmp, sub);
- delta = _mm_or_si128(delta, cmp);
- }
+ cmp = _mm_and_si128(cmp, sub);
+ delta = _mm_or_si128(delta, cmp);
in = _mm_add_epi8(in, delta);
_mm_storeu_si128((__m128i *)target, in);