master: Speed up arm64/character-string-utf8-length
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 992ff1465ea8a260e0fe09369057a123747dd219 (commit)
from 2df1a2bb309f96c75fb2905edc9a00179585de58 (commit)
- Log -----------------------------------------------------------------
commit 992ff1465ea8a260e0fe09369057a123747dd219
Author: Stas Boukarev <[email protected]>
Date: Tue Aug 11 00:07:32 2026 +0300
Speed up arm64/character-string-utf8-length
Use clz + tbl instead of multiple range checks.
---
src/code/arm64-simd.lisp | 27 +++++++++------------------
1 file changed, 9 insertions(+), 18 deletions(-)
diff --git a/src/code/arm64-simd.lisp b/src/code/arm64-simd.lisp
index 54fb947b8..de3cfdeb3 100644
--- a/src/code/arm64-simd.lisp
+++ b/src/code/arm64-simd.lisp
@@ -2149,17 +2149,15 @@
((chars-left unsigned-reg))
((tmp unsigned-reg))
- ((c-7f complex-double-reg))
- ((c-7ff complex-double-reg))
- ((c-ffff complex-double-reg))
((c-1b complex-double-reg))
+ ((length1 complex-double-reg t :offset 0))
+ ((length2 complex-double-reg t :offset 1))
((extra-len complex-double-reg))
((errors complex-double-reg))
((current complex-double-reg))
- ((tmp1 complex-double-reg))
- ((mask complex-double-reg)))
+ ((tmp1 complex-double-reg)))
((res descriptor-reg t :from :load)
(all-ascii descriptor-reg t :from :load))
@@ -2186,11 +2184,11 @@
(inst movi extra-len 0 :16b)
(inst movi errors 0 :16b)
- (inst movi c-7f #x7F :4s)
- (inst movi c-7ff #x7FF :4s)
- (inst movi c-ffff #x0000ffff0000ffff :2d)
(inst movi c-1b #x1b :4s)
+ (load-inline-constant length1 :oword #x03030303030303030303030303030300)
+ (load-inline-constant length2 :oword #x00000000000000010101010202020202)
+
(inst b START)
LOOP
@@ -2207,16 +2205,9 @@
(inst cmeq tmp1 tmp1 c-1b :4s)
(inst orr errors errors tmp1 :16b)
- (inst cmhi tmp1 current c-7f :4s)
-
- (inst cmhi mask current c-7ff :4s)
- (inst add tmp1 tmp1 mask :4s)
-
- (inst cmhi mask current c-ffff :4s)
- (inst add tmp1 tmp1 mask :4s)
-
- (inst saddlp tmp1 tmp1 :4s)
- (inst sub extra-len extra-len tmp1 :2d)
+ (inst clz tmp1 current :4s)
+ (inst tbl tmp1 (list length1 length2) tmp1 :16b)
+ (inst uadalp extra-len tmp1 :4s)
(inst b LOOP)
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL