Fix deadlocks in GC on Windows.
[sbcl.git] / src / compiler / x86-64 / arith.lisp
index 9229626..f455bff 100644 (file)
@@ -1328,13 +1328,17 @@ constant shift greater than word length")))
                         (:translate ,tran)
                         (:conditional ,(if signed cond unsigned))
                         (:generator ,cost
-                                    (inst cmp x
-                                          ,(case suffix
-                                             (-c/fixnum
-                                                `(constantize (fixnumize y)))
-                                             ((-c/signed -c/unsigned)
-                                                `(constantize y))
-                                             (t 'y))))))
+                          (cond ((and (sc-is x any-reg signed-reg unsigned-reg)
+                                      (eql y 0))
+                                 (inst test x x))
+                                (t
+                                 (inst cmp x
+                                       ,(case suffix
+                                          (-c/fixnum
+                                           `(constantize (fixnumize y)))
+                                          ((-c/signed -c/unsigned)
+                                           `(constantize y))
+                                          (t 'y))))))))
                    '(/fixnum -c/fixnum /signed -c/signed /unsigned -c/unsigned)
 ;                  '(/fixnum  /signed  /unsigned)
                    '(4 3 6 5 6 5)
@@ -1505,6 +1509,23 @@ constant shift greater than word length")))
   (def - t)
   (def * t))
 
+(define-modular-fun %negate-mod64 (x) %negate :untagged nil 64)
+(define-vop (%negate-mod64)
+  (:translate %negate-mod64)
+  (:policy :fast-safe)
+  (:args (x :scs (unsigned-reg) :target r))
+  (:arg-types unsigned-num)
+  (:results (r :scs (unsigned-reg)))
+  (:result-types unsigned-num)
+  (:generator 3
+    (move r x)
+    (inst neg r)))
+
+(define-modular-fun %negate-modfx (x) %negate :tagged t #.(- n-word-bits
+                                                             n-fixnum-tag-bits))
+(define-vop (%negate-modfx fast-negate/fixnum)
+  (:translate %negate-modfx))
+
 (define-vop (fast-ash-left-mod64-c/unsigned=>unsigned
              fast-ash-c/unsigned=>unsigned)
   (:translate ash-left-mod64))
@@ -1632,7 +1653,7 @@ constant shift greater than word length")))
 
 (define-full-reffer bignum-ref * bignum-digits-offset other-pointer-lowtag
   (unsigned-reg) unsigned-num sb!bignum:%bignum-ref)
-(define-full-reffer+offset bignum--ref-with-offset * bignum-digits-offset
+(define-full-reffer+offset bignum-ref-with-offset * bignum-digits-offset
   other-pointer-lowtag (unsigned-reg) unsigned-num
   sb!bignum:%bignum-ref-with-offset)
 (define-full-setter bignum-set * bignum-digits-offset other-pointer-lowtag