(:translate ,translate)
(:generator ,untagged-penalty
(move r x)
- (inst ,op r y))))))
-
- ;;(define-binop + 4 add)
+ ,(if (eq translate 'logand)
+ ;; for the -C/UNSIGNED=>UNSIGNED VOP, this case
+ ;; is optimized away as an identity somewhere
+ ;; along the lines. However, this VOP is used in
+ ;; -C/SIGNED=>UNSIGNED, below, when the
+ ;; higher-level lisp code can't optimize away the
+ ;; non-trivial identity.
+ `(unless (= y #.(1- (ash 1 n-word-bits)))
+ (inst ,op r y))
+ `(inst ,op r y)))))))
(define-binop - 4 sub)
(define-binop logand 2 and)
(define-binop logior 2 or)
(move r x)
(inst add r y)))))
-
;;;; Special logand cases: (logand signed unsigned) => unsigned
(define-vop (fast-logand/signed-unsigned=>unsigned
(move result prev)
(inst shrd result next :cl)))
-(define-source-transform 32bit-logical-not (x)
- `(logand (lognot (the (unsigned-byte 32) ,x)) #.(1- (ash 1 32))))
-
-(deftransform 32bit-logical-and ((x y))
- '(logand x y))
-
-(define-source-transform 32bit-logical-nand (x y)
- `(32bit-logical-not (32bit-logical-and ,x ,y)))
-
-(deftransform 32bit-logical-or ((x y))
- '(logior x y))
-
-(define-source-transform 32bit-logical-nor (x y)
- `(32bit-logical-not (32bit-logical-or ,x ,y)))
-
-(deftransform 32bit-logical-xor ((x y))
- '(logxor x y))
-
-(define-source-transform 32bit-logical-eqv (x y)
- `(32bit-logical-not (32bit-logical-xor ,x ,y)))
-
-(define-source-transform 32bit-logical-orc1 (x y)
- `(32bit-logical-or (32bit-logical-not ,x) ,y))
-
-(define-source-transform 32bit-logical-orc2 (x y)
- `(32bit-logical-or ,x (32bit-logical-not ,y)))
-
-(define-source-transform 32bit-logical-andc1 (x y)
- `(32bit-logical-and (32bit-logical-not ,x) ,y))
-
-(define-source-transform 32bit-logical-andc2 (x y)
- `(32bit-logical-and ,x (32bit-logical-not ,y)))
-
;;; Only the lower 5 bits of the shift amount are significant.
(define-vop (shift-towards-someplace)
(:policy :fast-safe)
fast-ash-c/unsigned=>unsigned)
(:translate ash-left-mod32))
+(define-vop (fast-ash-left-mod32/unsigned=>unsigned
+ fast-ash-left/unsigned=>unsigned))
+(deftransform ash-left-mod32 ((integer count)
+ ((unsigned-byte 32) (unsigned-byte 5)))
+ (when (sb!c::constant-lvar-p count)
+ (sb!c::give-up-ir1-transform))
+ '(%primitive fast-ash-left-mod32/unsigned=>unsigned integer count))
+
(in-package "SB!C")
(defknown sb!vm::%lea-mod32 (integer integer (member 1 2 4 8) (signed-byte 32))
(cut-to-width index width)
'sb!vm::%lea-mod32))
+#+sb-xc-host
+(defun sb!vm::%lea-mod32 (base index scale disp)
+ (ldb (byte 32 0) (%lea base index scale disp)))
+#-sb-xc-host
+(defun sb!vm::%lea-mod32 (base index scale disp)
+ (let ((base (logand base #xffffffff))
+ (index (logand index #xffffffff)))
+ ;; can't use modular version of %LEA, as we only have VOPs for
+ ;; constant SCALE and DISP.
+ (ldb (byte 32 0) (+ base (* index scale) disp))))
+
(in-package "SB!VM")
(define-vop (%lea-mod32/unsigned=>unsigned