mirror of
git://git.code.sf.net/p/sbcl/sbcl
synced 2026-09-10 07:26:40 -04:00
Better variable sb-rotate-byte.
The rotate instructions only look at the low bits of the rotate amount register. Which means rotating left a negative amount is the same rotating right (- negative-amount). Do that for x86-64 and arm64.
This commit is contained in:
parent
d74645fa7d
commit
f3e88e63e0
|
|
@ -25,16 +25,12 @@
|
|||
(:args (count :scs (sb-vm::signed-reg))
|
||||
(integer :scs (sb-vm::unsigned-reg)))
|
||||
(:arg-types sb-vm::tagged-num sb-vm::unsigned-num)
|
||||
(:temporary (:sc sb-vm::signed-reg) temp)
|
||||
(:results (res :scs (sb-vm::unsigned-reg)))
|
||||
(:result-types sb-vm::unsigned-num)
|
||||
(:generator 10
|
||||
(inst mov temp 32)
|
||||
(inst cmp count 0)
|
||||
(inst csel temp sb-vm::zr-tn temp :le)
|
||||
(inst sub temp temp count)
|
||||
(inst neg sb-vm::tmp-tn count)
|
||||
(inst ror (sb-vm::32-bit-reg res)
|
||||
(sb-vm::32-bit-reg integer) (sb-vm::32-bit-reg temp))))
|
||||
(sb-vm::32-bit-reg integer) (sb-vm::32-bit-reg sb-vm::tmp-tn))))
|
||||
|
||||
;;; 64-bit
|
||||
(define-vop (%64bit-rotate-byte/c)
|
||||
|
|
@ -59,12 +55,8 @@
|
|||
(:args (count :scs (sb-vm::signed-reg))
|
||||
(integer :scs (sb-vm::unsigned-reg)))
|
||||
(:arg-types sb-vm::tagged-num sb-vm::unsigned-num)
|
||||
(:temporary (:sc sb-vm::signed-reg) temp)
|
||||
(:results (res :scs (sb-vm::unsigned-reg)))
|
||||
(:result-types sb-vm::unsigned-num)
|
||||
(:generator 10
|
||||
(inst mov temp 64)
|
||||
(inst cmp count 0)
|
||||
(inst csel temp sb-vm::zr-tn temp :le)
|
||||
(inst sub temp temp count)
|
||||
(inst ror res integer temp)))
|
||||
(inst neg sb-vm::tmp-tn count)
|
||||
(inst ror res integer sb-vm::tmp-tn)))
|
||||
|
|
|
|||
|
|
@ -30,16 +30,9 @@
|
|||
(:results (result :scs (sb-vm::unsigned-reg) :from :load))
|
||||
(:result-types sb-vm::unsigned-num)
|
||||
(:generator 10
|
||||
(move result integer)
|
||||
(move rcx count :dword)
|
||||
(inst cmp :dword rcx 0)
|
||||
(inst jmp :ge label)
|
||||
(inst neg :dword rcx)
|
||||
(inst ror :dword result :cl)
|
||||
(inst jmp end)
|
||||
LABEL
|
||||
(inst rol :dword result :cl)
|
||||
END))
|
||||
(move result integer)
|
||||
(move rcx count :dword)
|
||||
(inst rol :dword result :cl)))
|
||||
|
||||
;;; 64-bit rotates
|
||||
|
||||
|
|
@ -70,13 +63,6 @@
|
|||
(:results (result :scs (sb-vm::unsigned-reg) :from :load))
|
||||
(:result-types sb-vm::unsigned-num)
|
||||
(:generator 10
|
||||
(move result integer)
|
||||
(move rcx count :dword)
|
||||
(inst cmp :dword rcx 0)
|
||||
(inst jmp :ge label)
|
||||
(inst neg :dword rcx)
|
||||
(inst ror result :cl)
|
||||
(inst jmp end)
|
||||
LABEL
|
||||
(inst rol result :cl)
|
||||
END))
|
||||
(move result integer)
|
||||
(move rcx count :dword)
|
||||
(inst rol result :cl)))
|
||||
|
|
|
|||
Loading…
Reference in a new issue