Index: /branches/rme-logops/compiler/X86/x862.lisp
===================================================================
--- /branches/rme-logops/compiler/X86/x862.lisp	(revision 13875)
+++ /branches/rme-logops/compiler/X86/x862.lisp	(revision 13876)
@@ -10094,4 +10094,14 @@
       (^))))
 
+(defx862 x862-%fixnum-mask-to-natural %fixnum-mask-to-natural (seg vreg xfer arg)
+  (with-imm-target () (target :natural)
+    (let ((r (x862-one-untargeted-reg-form seg arg *x862-arg-z*)))
+      (unless (or (acode-fixnum-form-p arg)
+		  *x862-reckless*)
+	(! trap-unless-finxum r))
+      (! fixnum->signed-natural target r)
+      (<- target)
+      (^))))
+
 (defx862 x862-%double-float %double-float (seg vreg xfer arg)
   (let* ((real (or (acode-fixnum-form-p arg)
Index: /branches/rme-logops/compiler/nx0.lisp
===================================================================
--- /branches/rme-logops/compiler/nx0.lisp	(revision 13875)
+++ /branches/rme-logops/compiler/nx0.lisp	(revision 13876)
@@ -2713,4 +2713,13 @@
     (subtypep (nx-form-type arg env) type env)))
 
+(defun nx-fixnum-op-p (form env)
+  (target-word-size-case
+   (32 (nx-form-typep form '(signed-byte 30) env))
+   (64 (nx-form-typep form '(signed-byte 61) env))))
+
+(defun nx-natural-op-p (form env)
+  (target-word-size-case
+   (32 (nx-form-typep form '(unsigned-byte 32) env))
+   (64 (nx-form-typep form '(unsigned-byte 64) env))))
 
 (defun nx-binary-fixnum-op-p (form1 form2 env &optional ignore-result-type)
@@ -2746,6 +2755,41 @@
              (64 (subtypep *nx-form-type* '(unsigned-byte 64))))))))
 
-    
-
+(defun nx-logand-2-op (arg-1 arg-2 env)
+  (let ((fix-1 (nx-fixnum-op-p arg-1 env))
+	(fix-2 (nx-fixnum-op-p arg-2 env))
+	(nat-1 (nx-natural-op-p arg-1 env))
+	(nat-2 (nx-natural-op-p arg-2 env))
+	(form-1 (nx1-form arg-1))
+	(form-2 (nx1-form arg-2)))
+    (cond
+      ((and fix-1 fix-2)
+       (make-acode (%nx1-operator %ilogand2) form-1 form-2))
+      ((and nat-1 nat-2)
+       (make-acode (%nx1-operator typed-form)
+		   (target-word-size-case
+		    (32 '(unsigned-byte 32))
+		    (64 '(unsigned-byte 64)))
+		   (make-acode (%nx1-operator %natural-logand) form-1 form-2)))
+      ((and fix-1 nat-2)
+       (make-acode (%nx1-operator typed-form)
+		   (target-word-size-case
+		    (32 '(unsigned-byte 32))
+		    (64 '(unsigned-byte 64)))
+		   (make-acode (%nx1-operator %natural-logand)
+			       (make-acode (%nx1-operator %fixnum-mask-to-natural)
+					   form-1)
+			       form-2)))
+      ((and nat-1 fix-2)
+       (make-acode (%nx1-operator typed-form)
+		   (target-word-size-case
+		    (32 '(unsigned-byte 32))
+		    (64 '(unsigned-byte 64)))
+		   (make-acode (%nx1-operator %natural-logand)
+			       form-1
+			       (make-acode (%nx1-operator %fixnum-mask-to-natural)
+							  form-2))))
+      (t
+       (make-acode (%nx1-operator logand2) form-1 form-2)))))
+	  
 
 (defun nx-binary-boole-op (whole env arg-1 arg-2 fixop intop naturalop)
Index: /branches/rme-logops/compiler/nx1.lisp
===================================================================
--- /branches/rme-logops/compiler/nx1.lisp	(revision 13875)
+++ /branches/rme-logops/compiler/nx1.lisp	(revision 13876)
@@ -468,4 +468,8 @@
 		      (%nx1-operator %natural-logxor)))
 
+(defnx1 nx1-logand-2 ((logand-2)) (&environment env arg-1 arg-2)
+  (nx-logand-2-op arg-1 arg-2 env))
+
+#+not-any-more
 (defnx1 nx1-logand-2 ((logand-2)) (&whole w &environment env arg-1 arg-2)
   (nx-binary-boole-op w 
@@ -2198,4 +2202,8 @@
               (nx1-form arg)))
 
+(defnx1 nx1-%fixnum-mask-to-natural ((%fixnum-mask-to-natural)) (arg)
+  (make-acode (%nx1-operator %fixnum-mask-to-natural)
+              (nx1-form arg)))
+
 (defnx1 nx1-%double-float ((%double-float)) (&whole whole arg &optional (result nil result-p))
   (declare (ignore result))
Index: /branches/rme-logops/compiler/nxenv.lisp
===================================================================
--- /branches/rme-logops/compiler/nxenv.lisp	(revision 13875)
+++ /branches/rme-logops/compiler/nxenv.lisp	(revision 13876)
@@ -370,5 +370,6 @@
      (%double-float . #. #.(logior operator-acode-subforms-mask operator-assignment-free-mask operator-single-valued-mask))
      (i386-ff-call . 0)
-     (i386-syscall . 0))))
+     (i386-syscall . 0)
+     (%fixnum-mask-to-natural  . #.(logior operator-assignment-free-mask operator-single-valued-mask operator-acode-subforms-mask operator-side-effect-free-mask)))))
 
 (defmacro %nx1-operator (sym)
