1.0.15.19: use TEST X X when possible in SIGNED-BYTE-*-LEN VOPS
[sbcl.git] / src / compiler / x86 / arith.lisp
index 7511b32..970b369 100644 (file)
 
 (define-vop (fast-lognot/fixnum fixnum-unop)
   (:translate lognot)
-  (:generator 2
+  (:generator 1
     (move res x)
     (inst xor res (fixnumize -1))))
 
 (define-vop (fast-lognot/signed signed-unop)
   (:translate lognot)
-  (:generator 1
+  (:generator 2
     (move res x)
     (inst not res)))
 \f
   (:result-types unsigned-num)
   (:generator 28
     (move res arg)
-    (inst cmp res 0)
+    (if (sc-is res unsigned-reg)
+        (inst test res res)
+        (inst cmp res 0))
     (inst jmp :ge POS)
     (inst not res)
     POS
                    (svop30f (intern (format nil "FAST-~S-SMOD30/FIXNUM=>FIXNUM" name)))
                    (svop30cf (intern (format nil "FAST-~S-SMOD30-C/FIXNUM=>FIXNUM" name))))
                `(progn
-                  (define-modular-fun ,fun32 (x y) ,name :unsigned 32)
-                  (define-modular-fun ,sfun30 (x y) ,name :signed 30)
+                  (define-modular-fun ,fun32 (x y) ,name :untagged nil 32)
+                  (define-modular-fun ,sfun30 (x y) ,name :tagged t 30)
                   (define-mod-binop (,vop32u ,vopu) ,fun32)
                   (define-vop (,vop32f ,vopf) (:translate ,fun32))
                   (define-vop (,svop30f ,vopf) (:translate ,sfun30))
   (signed-byte 30)
   (foldable flushable movable))
 
-(define-modular-fun-optimizer %lea ((base index scale disp) :unsigned :width width)
+(define-modular-fun-optimizer %lea ((base index scale disp) :untagged nil :width width)
   (when (and (<= width 32)
              (constant-lvar-p scale)
              (constant-lvar-p disp))
-    (cut-to-width base :unsigned width)
-    (cut-to-width index :unsigned width)
+    (cut-to-width base :untagged width nil)
+    (cut-to-width index :untagged width nil)
     'sb!vm::%lea-mod32))
-(define-modular-fun-optimizer %lea ((base index scale disp) :signed :width width)
+(define-modular-fun-optimizer %lea ((base index scale disp) :tagged t :width width)
   (when (and (<= width 30)
              (constant-lvar-p scale)
              (constant-lvar-p disp))
-    (cut-to-width base :signed width)
-    (cut-to-width index :signed width)
+    (cut-to-width base :tagged width t)
+    (cut-to-width index :tagged width t)
     'sb!vm::%lea-smod30))
 
 #+sb-xc-host
   (:translate %lea-smod30))
 
 ;;; logical operations
-(define-modular-fun lognot-mod32 (x) lognot :unsigned 32)
+(define-modular-fun lognot-mod32 (x) lognot :untagged nil 32)
 (define-vop (lognot-mod32/word=>unsigned)
   (:translate lognot-mod32)
   (:args (x :scs (unsigned-reg signed-reg unsigned-stack signed-stack) :target r
     (move r x)
     (inst not r)))
 
-(define-modular-fun logxor-mod32 (x y) logxor :unsigned 32)
-(define-mod-binop (fast-logxor-mod32/word=>unsigned
-                   fast-logxor/unsigned=>unsigned)
-    logxor-mod32)
-(define-mod-binop-c (fast-logxor-mod32-c/word=>unsigned
-                     fast-logxor-c/unsigned=>unsigned)
-    logxor-mod32)
-(define-vop (fast-logxor-mod32/fixnum=>fixnum
-             fast-logxor/fixnum=>fixnum)
-  (:translate logxor-mod32))
-(define-vop (fast-logxor-mod32-c/fixnum=>fixnum
-             fast-logxor-c/fixnum=>fixnum)
-  (:translate logxor-mod32))
-
 (define-source-transform logeqv (&rest args)
   (if (oddp (length args))
       `(logxor ,@args)