-(define-vop (check-signed-byte-32 check-type)
- (:generator 8
- (let ((nope (generate-error-code vop
- object-not-signed-byte-32-error
- value))
- (ok (gen-label)))
- (move rax-tn value)
- (inst test rax-tn 7)
- (inst jmp :ne nope)
- (inst sar rax-tn (+ 32 3 -1))
- (inst jmp :z ok)
- (inst cmp rax-tn -1)
+(define-vop (fixnump/signed-byte-64 type-predicate)
+ (:args (value :scs (signed-reg)))
+ (:info)
+ (:conditional #.(if (= sb!vm:n-fixnum-tag-bits 1) :ns :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)
+ (unless (= n-fixnum-tag-bits 1)
+ (inst shr rax-tn n-fixnum-bits))))
+
+;;; A (SIGNED-BYTE 64) can be represented with either fixnum or a bignum with
+;;; exactly one digit.
+
+(define-vop (signed-byte-64-p type-predicate)
+ (:translate signed-byte-64-p)
+ (:generator 45
+ (multiple-value-bind (yep nope)
+ (if not-p
+ (values not-target target)
+ (values target not-target))
+ (generate-fixnum-test value)
+ (inst jmp :e yep)
+ (move-qword-to-eax value)
+ (inst and al-tn lowtag-mask)
+ (inst cmp al-tn other-pointer-lowtag)