1.0.28.5: delete MERGE-BITS
[sbcl.git] / src / compiler / mips / arith.lisp
index b26bab9..70649f5 100644 (file)
 \f
 ;;;; Unary operations.
 
-(define-vop (fixnum-unop)
+(define-vop (fast-safe-arith-op)
+  (:policy :fast-safe)
+  (:effects)
+  (:affected))
+
+(define-vop (fixnum-unop fast-safe-arith-op)
   (:args (x :scs (any-reg)))
   (:results (res :scs (any-reg)))
   (:note "inline fixnum arithmetic")
   (:arg-types tagged-num)
-  (:result-types tagged-num)
-  (:policy :fast-safe))
+  (:result-types tagged-num))
 
-(define-vop (signed-unop)
+(define-vop (signed-unop fast-safe-arith-op)
   (:args (x :scs (signed-reg)))
   (:results (res :scs (signed-reg)))
   (:note "inline (signed-byte 32) arithmetic")
   (:arg-types signed-num)
-  (:result-types signed-num)
-  (:policy :fast-safe))
+  (:result-types signed-num))
 
 (define-vop (fast-negate/fixnum fixnum-unop)
   (:translate %negate)
   (:temporary (:scs (any-reg) :type fixnum :to (:result 0))
               temp)
   (:translate lognot)
-  (:generator 2
+  (:generator 1
     (inst li temp (fixnumize -1))
     (inst xor res x temp)))
 
 (define-vop (fast-lognot/signed signed-unop)
   (:translate lognot)
-  (:generator 1
+  (:generator 2
     (inst nor res x zero-tn)))
-
-
 \f
 ;;;; Binary fixnum operations.
 
 ;;; Assume that any constant operand is the second arg...
 
-(define-vop (fast-fixnum-binop)
-  (:args (x :target r :scs (any-reg))
-         (y :target r :scs (any-reg)))
+(define-vop (fast-fixnum-binop fast-safe-arith-op)
+  (:args (x :target r :scs (any-reg zero))
+         (y :target r :scs (any-reg zero)))
   (:arg-types tagged-num tagged-num)
   (:results (r :scs (any-reg)))
   (:result-types tagged-num)
-  (:note "inline fixnum arithmetic")
-  (:effects)
-  (:affected)
-  (:policy :fast-safe))
+  (:note "inline fixnum arithmetic"))
 
-(define-vop (fast-unsigned-binop)
-  (:args (x :target r :scs (unsigned-reg))
-         (y :target r :scs (unsigned-reg)))
+(define-vop (fast-unsigned-binop fast-safe-arith-op)
+  (:args (x :target r :scs (unsigned-reg zero))
+         (y :target r :scs (unsigned-reg zero)))
   (:arg-types unsigned-num unsigned-num)
   (:results (r :scs (unsigned-reg)))
   (:result-types unsigned-num)
-  (:note "inline (unsigned-byte 32) arithmetic")
-  (:effects)
-  (:affected)
-  (:policy :fast-safe))
+  (:note "inline (unsigned-byte 32) arithmetic"))
 
-(define-vop (fast-signed-binop)
-  (:args (x :target r :scs (signed-reg))
-         (y :target r :scs (signed-reg)))
+(define-vop (fast-signed-binop fast-safe-arith-op)
+  (:args (x :target r :scs (signed-reg zero))
+         (y :target r :scs (signed-reg zero)))
   (:arg-types signed-num signed-num)
   (:results (r :scs (signed-reg)))
   (:result-types signed-num)
-  (:note "inline (signed-byte 32) arithmetic")
-  (:effects)
-  (:affected)
-  (:policy :fast-safe))
+  (:note "inline (signed-byte 32) arithmetic"))
 
 (define-vop (fast-fixnum-c-binop fast-fixnum-binop)
   (:args (x :target r :scs (any-reg)))
 
 (define-binop + 1 5 addu (signed-byte 14) (signed-byte 16))
 (define-binop - 1 5 subu
-  (integer #.(- (1- (ash 1 14))) #.(ash 1 14))
-  (integer #.(- (1- (ash 1 16))) #.(ash 1 16)))
+  (integer #.(- 1 (ash 1 13)) #.(ash 1 13))
+  (integer #.(- 1 (ash 1 15)) #.(ash 1 15)))
 (define-binop logior 1 3 or (unsigned-byte 14) (unsigned-byte 16))
 (define-binop logand 1 3 and (unsigned-byte 14) (unsigned-byte 16))
 (define-binop logxor 1 3 xor (unsigned-byte 14) (unsigned-byte 16))
     (inst bgez amount positive)
     (inst subu ndesc zero-tn amount)
     (inst slt temp ndesc 32)
-    (inst bne temp zero-tn done)
+    (inst bne temp done)
     (inst srl result number ndesc)
     (inst b done)
     (move result zero-tn t)
     (inst bgez amount positive)
     (inst subu ndesc zero-tn amount)
     (inst slt temp ndesc 31)
-    (inst bne temp zero-tn done)
+    (inst bne temp done)
     (inst sra result number ndesc)
     (inst b done)
     (inst sra result number 31)
   (:save-p :compute-only)
   (:generator 11
     (let ((zero (generate-error-code vop division-by-zero-error x y)))
-      (inst beq y zero-tn zero))
+      (inst beq y zero))
     (inst nop)
     (inst div x y)
     (inst mflo temp)
   (:save-p :compute-only)
   (:generator 12
     (let ((zero (generate-error-code vop division-by-zero-error x y)))
-      (inst beq y zero-tn zero))
+      (inst beq y zero))
     (inst nop)
     (inst divu x y)
     (inst mflo q)
   (:save-p :compute-only)
   (:generator 12
     (let ((zero (generate-error-code vop division-by-zero-error x y)))
-      (inst beq y zero-tn zero))
+      (inst beq y zero))
     (inst nop)
     (inst div x y)
     (inst mflo q)
              (inst slt temp x y)
              (inst sltu temp x y))
          (if not-p
-             (inst beq temp zero-tn target)
-             (inst bne temp zero-tn target))))
+             (inst beq temp target)
+             (inst bne temp target))))
   (inst nop))
 
 (define-conditional-vop >
                (inst slt temp x y)
                (inst sltu temp x y))
            (if not-p
-               (inst bne temp zero-tn target)
-               (inst beq temp zero-tn target))))
+               (inst bne temp target)
+               (inst beq temp target))))
         (t
          (if signed
              (inst slt temp y x)
              (inst sltu temp y x))
          (if not-p
-             (inst beq temp zero-tn target)
-             (inst bne temp zero-tn target))))
+             (inst beq temp target)
+             (inst bne temp target))))
   (inst nop))
 
 ;;; EQL/FIXNUM is funny because the first arg can be of any type, not just a
 \f
 ;;;; 32-bit logical operations
 
-(define-vop (merge-bits)
-  (:translate merge-bits)
-  (:args (shift :scs (signed-reg unsigned-reg))
-         (prev :scs (unsigned-reg))
-         (next :scs (unsigned-reg)))
-  (:arg-types tagged-num unsigned-num unsigned-num)
-  (:temporary (:scs (unsigned-reg) :to (:result 0)) temp)
-  (:temporary (:scs (unsigned-reg) :to (:result 0) :target result) res)
-  (:results (result :scs (unsigned-reg)))
-  (:result-types unsigned-num)
-  (:policy :fast-safe)
-  (:generator 4
-    (let ((done (gen-label)))
-      (inst beq shift done)
-      (inst srl res next shift)
-      (inst subu temp zero-tn shift)
-      (inst sll temp prev temp)
-      (inst or res res temp)
-      (emit-label done)
-      (move result res))))
-
 (define-vop (shift-towards-someplace)
   (:policy :fast-safe)
   (:args (num :scs (unsigned-reg))
        (inst sll r num amount)))))
 \f
 ;;;; Modular arithmetic
-(define-modular-fun +-mod32 (x y) + :unsigned 32)
+(define-modular-fun +-mod32 (x y) + :untagged nil 32)
 (define-vop (fast-+-mod32/unsigned=>unsigned fast-+/unsigned=>unsigned)
   (:translate +-mod32))
 (define-vop (fast-+-mod32-c/unsigned=>unsigned fast-+-c/unsigned=>unsigned)
   (:translate +-mod32))
-(define-modular-fun --mod32 (x y) - :unsigned 32)
+(define-modular-fun --mod32 (x y) - :untagged nil 32)
 (define-vop (fast---mod32/unsigned=>unsigned fast--/unsigned=>unsigned)
   (:translate --mod32))
 (define-vop (fast---mod32-c/unsigned=>unsigned fast---c/unsigned=>unsigned)
   '(%primitive fast-ash-left-mod32/unsigned=>unsigned integer count))
 
 ;;; 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/unsigned=>unsigned)
   (:translate lognot-mod32)
   (:args (x :scs (unsigned-reg)))
   (:generator 1
     (inst nor r x zero-tn)))
 
-(define-modular-fun logxor-mod32 (x y) logxor :unsigned 32)
-(define-vop (fast-logxor-mod32/unsigned=>unsigned
-             fast-logxor/unsigned=>unsigned)
-  (:translate logxor-mod32))
-(define-vop (fast-logxor-mod32-c/unsigned=>unsigned
-             fast-logxor-c/unsigned=>unsigned)
-  (:translate logxor-mod32))
-
-(define-modular-fun lognor-mod32 (x y) lognor :unsigned 32)
+(define-modular-fun lognor-mod32 (x y) lognor :untagged nil 32)
 (define-vop (fast-lognor-mod32/unsigned=>unsigned
              fast-lognor/unsigned=>unsigned)
   (:translate lognor-mod32))