From 287e258e1c7ae7d3e5c46e546a86b77b0013161b Mon Sep 17 00:00:00 2001 From: Weilin Du Date: Sun, 20 Sep 2026 23:47:49 +0800 Subject: [PATCH] ext/standard: Remove redundant if-branch in rot13 --- UPGRADING | 1 + ext/standard/string.c | 24 ++++++++---------------- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/UPGRADING b/UPGRADING index a8ae2045f899..81eaf515d7f2 100644 --- a/UPGRADING +++ b/UPGRADING @@ -1145,6 +1145,7 @@ PHP 8.6 UPGRADE NOTES . Improved performance of str_split(). . Improved performance of str_pad(). . Improved performance of str_repeat() when the multiplier is 1. + . Removed redundant branches from the SSE2 implementation of str_rot13(). - URI: . Improved performance of Uri\WhatWg\Url::parse() when collecting diff --git a/ext/standard/string.c b/ext/standard/string.c index 441890ea2902..627e2158aa07 100644 --- a/ext/standard/string.c +++ b/ext/standard/string.c @@ -6037,34 +6037,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);