* No need to cons up a bignum, and just one branch required.
Eliminates a whole class of signed-word to integer coercions.
;;;; -*- coding: utf-8; fill-column: 78 -*-
+ * optimization: more efficient type-checks for FIXNUMs when the value
+ is known to be a signed word on x86 and x86-64.
* bug fix: on 64 bit platforms FILL worked incorrectly on arrays with
upgraded element type (COMPLEX SINGLE-FLOAT), regression from 1.0.28.55.
(thanks to Paul Khuong)
(inst mov tmp value)
(inst shr tmp n-positive-fixnum-bits)))
+(define-vop (fixnump/signed-byte-64 type-predicate)
+ (:args (value :scs (signed-reg)))
+ (:info)
+ (:conditional :z)
+ (:arg-types signed-num)
+ (:translate fixnump)
+ (:generator 5
+ ;; Hackers Delight, p. 53: signed
+ ;; a <= x <= a + 2^n - 1
+ ;; is equivalent to unsigned
+ ;; ((x-a) >> n) = 0
+ (inst mov rax-tn #.(- sb!xc:most-negative-fixnum))
+ (inst add rax-tn value)
+ (inst shr rax-tn #.(integer-length (- sb!xc:most-positive-fixnum
+ sb!xc:most-negative-fixnum)))))
+
;;; A (SIGNED-BYTE 64) can be represented with either fixnum or a bignum with
;;; exactly one digit.
(:arg-types unsigned-num)
(:translate fixnump)
(:generator 5
+ ;; We could encode this with :Z and SHR, analogously to the signed-byte-32
+ ;; case below -- as we do on x86-64 -- but that costs us an extra
+ ;; register. Compromises...
(inst cmp value #.sb!xc:most-positive-fixnum)))
+(define-vop (fixnump/signed-byte-32 type-predicate)
+ (:args (value :scs (signed-reg)))
+ (:info)
+ (:conditional :z)
+ (:arg-types signed-num)
+ (:translate fixnump)
+ (:generator 5
+ ;; Hackers Delight, p. 53: signed
+ ;; a <= x <= a + 2^n - 1
+ ;; is equivalent to unsigned
+ ;; ((x-a) >> n) = 0
+ (inst mov eax-tn value)
+ (inst sub eax-tn #.sb!xc:most-negative-fixnum)
+ (inst shr eax-tn #.(integer-length (- sb!xc:most-positive-fixnum
+ sb!xc:most-negative-fixnum)))))
+
;;; A (SIGNED-BYTE 32) can be represented with either fixnum or a bignum with
;;; exactly one digit.
;;; checkins which aren't released. (And occasionally for internal
;;; versions, especially for internal versions off the main CVS
;;; branch, it gets hairier, e.g. "0.pre7.14.flaky4.13".)
-"1.0.29.1"
+"1.0.29.2"