master: avx2/utf8-strlen: fix the 1/2 byte fast path
stassats via Sbcl-commits <[email protected]>
| Newsgroups | gmane.lisp.steel-bank.cvs |
|---|---|
| Message-ID | <[email protected]> |
The branch "master" has been updated in SBCL:
via ff86fee2c08362a89ff782d500509bdab2280c19 (commit)
from c104c75a3ced9efb23860f3f60a3ec44e9fba6e4 (commit)
- Log -----------------------------------------------------------------
commit ff86fee2c08362a89ff782d500509bdab2280c19
Author: Stas Boukarev <[email protected]>
Date: Mon Aug 24 03:33:31 2026 +0300
avx2/utf8-strlen: fix the 1/2 byte fast path
Which omits overlongs coming from the full path.
---
src/code/x86-64-simd.lisp | 19 +++++++++----------
1 file changed, 9 insertions(+), 10 deletions(-)
diff --git a/src/code/x86-64-simd.lisp b/src/code/x86-64-simd.lisp
index 498e9000e..c3b35554c 100644
--- a/src/code/x86-64-simd.lisp
+++ b/src/code/x86-64-simd.lisp
@@ -2465,8 +2465,12 @@
(inst test :dword tmp tmp)
(inst jmp :z VALIDATED)
+ (inst vperm2i128 tmp1 prev current #x21)
+ (inst vpalignr tmp1 current tmp1 15)
+
(inst vpsubusb tmp2 tmp2 (inline-const #xDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDFDF))
(inst vptest tmp2 tmp2)
+
(inst jmp :nz full)
;; 1/2 bytes
@@ -2478,19 +2482,17 @@
(inst vpand tmp4 tmp4 tmp2) ;; it's a signed comparison, remove ascii
;; Find #xC0 or #xC1, which are overlong
- (inst vpandn tmp1 tmp3 tmp2) ;; neither ascii or continuations
- (inst vpxor tmp1 tmp1 tmp4) ;; nor a valid leading byte
+ (inst vpandn tmp2 tmp3 tmp2) ;; neither ascii or continuations
+ (inst vpxor tmp2 tmp2 tmp4) ;; nor a valid leading byte
;; Continuations must follow leading bytes,
;; they must align with the shifted input
- (inst vpcmpgtb tmp2 prev-len zeros)
-
;; Identify leading non-ascii bytes, shifted left by
;; one byte, with the previous byte shifted in
- (inst vperm2i128 tmp2 tmp2 tmp4 #x21)
- (inst vpalignr tmp2 tmp4 tmp2 15)
- (inst vpxor tmp2 tmp2 tmp3)
+ (inst vpsubusb tmp1 tmp1 (inline-const #xC1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1C1))
+ (inst vpcmpgtb tmp1 tmp1 zeros)
+ (inst vpxor tmp1 tmp1 tmp3)
(inst vpor tmp1 tmp1 tmp2)
(inst vpor errors errors tmp1)
@@ -2503,9 +2505,6 @@
(inst jmp VALIDATED)
FULL
;; The Keiser, Lemire algorithm
- (inst vperm2i128 tmp1 prev current #x21)
- (inst vpalignr tmp1 current tmp1 15)
-
(inst vpsrlw tmp2 tmp1 4)
(inst vpand tmp2 tmp2 mask-0f)
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL