master: arm64/character-string-to-utf8: reduce a LUT by 4KB
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 977441e82786a2fb868fa926c343d087a0ace5a0 (commit)
from 4c9ebabb78165a6d7e4d8cfefa1bec5b30d5e5e3 (commit)
- Log -----------------------------------------------------------------
commit 977441e82786a2fb868fa926c343d087a0ace5a0
Author: Stas Boukarev <[email protected]>
Date: Sat Aug 15 05:21:33 2026 +0300
arm64/character-string-to-utf8: reduce a LUT by 4KB
A mask that clears the high bits can be generated from the tag bits
with a single right shift.
---
src/code/arm64-simd.lisp | 26 ++++++++------------------
1 file changed, 8 insertions(+), 18 deletions(-)
diff --git a/src/code/arm64-simd.lisp b/src/code/arm64-simd.lisp
index 7c9bd4a32..7c01eb4a2 100644
--- a/src/code/arm64-simd.lisp
+++ b/src/code/arm64-simd.lisp
@@ -1430,8 +1430,8 @@
((length1 complex-double-reg t :offset 8))
((length2 complex-double-reg t :offset 9))
((shuf-mask complex-double-reg t :offset 10))
- ((and-mask complex-double-reg t :offset 11))
- ((orr-mask complex-double-reg t :offset 12))
+ ((orr-mask complex-double-reg t :offset 11))
+
((zeros complex-double-reg))
((:label error)))
((string any-reg positive-fixnum :from (:argument 0))
@@ -1439,7 +1439,7 @@
(last-newline signed-reg signed-num :from :load))
(flet ((make-full-table ()
(let* ((table-size 256)
- (row-size (* 16 3))
+ (row-size (* 16 2))
(table (make-array (* table-size row-size) :element-type '(unsigned-byte 8)
:initial-element 0)))
@@ -1458,13 +1458,6 @@
for reg-index = (+ zeros b)
for src-index = (+ (* reg-index 16) (* lane 4))
for lead-p = (= b 0)
- for and-mask = (if lead-p
- (case bytes
- (1 #x7F)
- (2 #x1F)
- (3 #x0F)
- (4 #x07))
- #x3F)
for orr-mask = (if lead-p
(case bytes
(1 #x00)
@@ -1473,8 +1466,7 @@
(4 #xF0))
#x80)
do (setf (aref table (+ (* row row-size) dest-index)) src-index) ;; tbl
- (setf (aref table (+ (* row row-size) 16 dest-index)) and-mask) ;; and
- (setf (aref table (+ (* row row-size) 32 dest-index)) orr-mask) ;; orr
+ (setf (aref table (+ (* row row-size) 16 dest-index)) orr-mask) ;; orr
(incf dest-index))))
table)))
(assemble ()
@@ -1575,15 +1567,13 @@
(inst add tmp-tn tmp-tn (lsr tmp-tn 4))
(inst and tmp-tn tmp-tn #x0F))
- ;; Multiply by 48 (3 * 16)
- (inst add tmp tmp (lsl tmp 1))
- (inst add tmp full-table (lsl tmp 4))
-
- (inst ld1 (list shuf-mask and-mask orr-mask) (@ tmp) :16b)
+ (inst add tmp full-table (lsl tmp 5))
+ (inst ld1 (list shuf-mask orr-mask) (@ tmp) :16b)
(inst tbl bytes (list f1 f2 f3 bytes) shuf-mask :16b)
- (inst and bytes bytes and-mask :16b)
+ (inst sshr temp orr-mask 1 :16b)
+ (inst bic bytes bytes temp :16b)
(inst orr bytes bytes orr-mask :16b)
(inst str bytes (@ byte-array 4 :post-index))
-----------------------------------------------------------------------
hooks/post-receive
--
SBCL