1.0.32.12: Fix slot-value on specialized parameters in SVUC methods
[sbcl.git] / src / compiler / x86 / type-vops.lisp
index d0e5f0e..0284ae4 100644 (file)
 
 (define-vop (fixnump/unsigned-byte-32 simple-type-predicate)
   (:args (value :scs (unsigned-reg)))
+  (:info)
+  (:conditional :be)
   (:arg-types unsigned-num)
   (:translate fixnump)
   (:generator 5
-    (inst cmp value #.sb!xc:most-positive-fixnum)
-    (inst jmp (if not-p :a :be) target)))
+    ;; 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.