Fix deadlocks in GC on Windows.
[sbcl.git] / src / compiler / x86-64 / arith.lisp
index c50e0dd..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)