summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStas Boukarev <stassats@gmail.com>2024-05-19 21:25:42 +0300
committerStas Boukarev <stassats@gmail.com>2024-05-19 21:29:33 +0300
commitd0d0782311e97ce6607797250e129e873873f786 (patch)
tree815c8bbf88acd0685c485926187405b72afcc0e8
parent73b2555c2deb580cd59b441ba159be1255e73da6 (diff)
Remove bignum-negate-loop. It's used only in one place.
-rw-r--r--src/code/bignum.lisp25
-rw-r--r--src/compiler/arm64/insts.lisp2
2 files changed, 22 insertions, 5 deletions
diff --git a/src/code/bignum.lisp b/src/code/bignum.lisp
index 116503641..4fc3cfc88 100644
--- a/src/code/bignum.lisp
+++ b/src/code/bignum.lisp
@@ -1024,13 +1024,14 @@
(loop with carry = 1
with i = 0
do
- (when (= i len-x)
- (return))
+
(setf last1 last2)
(setf (values last2 carry)
(%add-with-carry (%lognot (%bignum-ref x i)) 0 carry))
(setf (%bignum-ref res i) last2)
- (incf i)))
+ (incf i)
+ (when (= i len-x)
+ (return))))
(when (/= len-res len-x)
(setf (%bignum-ref res len-x) 0)
(shiftf last1 last2 0))
@@ -1049,7 +1050,23 @@
;;; stay in the provided allocated bignum.
(declaim (maybe-inline negate-bignum-buffer-in-place))
(defun negate-bignum-buffer-in-place (bignum bignum-len)
- (bignum-negate-loop bignum bignum-len bignum)
+ (let* ((carry
+ (multiple-value-bind (value carry)
+ (%add-with-carry (%lognot (%bignum-ref bignum 0)) 1 0)
+ (setf (%bignum-ref bignum 0) value)
+ carry))
+ (i 1)
+ (end bignum-len))
+ (declare (type bit carry)
+ (type bignum-index i)
+ (type bignum-length end))
+ (loop (when (= i end) (return))
+ (multiple-value-bind (value temp)
+ (%add-with-carry (%lognot (%bignum-ref bignum i)) 0 carry)
+ (setf (%bignum-ref bignum i) value)
+ (setf carry temp))
+ (incf i))
+ carry)
bignum)
(defun negate-bignum-in-place (bignum)
diff --git a/src/compiler/arm64/insts.lisp b/src/compiler/arm64/insts.lisp
index f7dde9c55..ec2e04dc1 100644
--- a/src/compiler/arm64/insts.lisp
+++ b/src/compiler/arm64/insts.lisp
@@ -3563,7 +3563,7 @@
(memq (vop-name vop) safe-vops)
(and vop
(loop for fun in safe-translates
- thereis (memq (sb-c::vop-info vop)
+ thereis (memq (sb-c::vop-info vop)
(sb-c::fun-info-templates (sb-c::fun-info-or-lose fun)))))
(and (not safe-vops)
(not safe-translates))))))))