Index: /branches/ia32/compiler/X86/X8632/x8632-vinsns.lisp
===================================================================
--- /branches/ia32/compiler/X86/X8632/x8632-vinsns.lisp	(revision 8366)
+++ /branches/ia32/compiler/X86/X8632/x8632-vinsns.lisp	(revision 8367)
@@ -210,16 +210,20 @@
 
 (define-x8632-vinsn set-nargs (()
-			       ((n :s16const)))
-  ((:pred = n 0)
-   (xorw (:%w x8632::nargs ) (:%w x8632::nargs )))
-  ((:not (:pred = n 0))
-   (movw (:$w (:apply ash n x8632::fixnum-shift)) (:%w x8632::nargs ))))
+			       ((n :u16const)))
+  ((:pred < n 32)
+   (xorl (:%l x8632::nargs) (:%l x8632::nargs))
+   ((:pred > n 0)
+    (addl (:$b (:apply ash n x8632::fixnumshift)) (:%l x8632::nargs))))
+  ((:pred >= n 32)
+   (movl (:$l (:apply ash n x8632::fixnumshift)) (:%l x8632::nargs))))
 
 (define-x8632-vinsn check-exact-nargs (()
                                        ((n :u16const)))
   ((:pred = n 0)
-   (testw (:%w x8632::nargs) (:%w x8632::nargs)))
-  ((:not (:pred = n 0))
-   (cmpw (:$w (:apply ash n x8632::fixnum-shift)) (:%w x8632::nargs)))
+   (testl (:%l x8632::nargs) (:%l x8632::nargs)))
+  ((:and (:pred > n 0) (:pred < n 32))
+   (cmpl (:$b (:apply ash n x8632::fixnumshift)) (:%l x8632::nargs)))
+  ((:pred >= n 32))
+   (cmpl (:$l (:apply ash n x8632::fixnumshift)) (:%l x8632::nargs))
   (jz.pt :ok)
   (uuo-error-wrong-number-of-args)
@@ -227,6 +231,12 @@
 
 (define-x8632-vinsn check-min-nargs (()
-                                       ((n :u16const)))
-  (rcmpw (:%w x8632::nargs) (:$w (:apply ash n x8632::fixnum-shift)))
+				     ((min :u16const)))
+  ((:pred = min 1)
+   (testl (:%l x8632::nargs) (:%l x8632::nargs))
+   (jnz :ok))
+  ((:and (:pred > min 1) (:pred < min 32))
+   (rcmpl (:%l x8632::nargs) (:$b (:apply ash min x8632::fixnumshift))))
+  ((:pred >= min 32)
+   (rcmpl (:%l x8632::nargs) (:$l (:apply ash min x8632::fixnumshift))))
   (jae.pt :ok)
   (uuo-error-too-few-args)
@@ -234,6 +244,9 @@
 
 (define-x8632-vinsn check-max-nargs (()
-                                       ((n :u16const)))
-  (rcmpw (:%w x8632::nargs) (:$w (:apply ash n x8632::fixnum-shift)))
+				     ((n :u16const)))
+  ((:pred < n 32)
+   (rcmpl (:%l x8632::nargs) (:$b (:apply ash n x8632::fixnumshift))))
+  ((:pred >= n 32)
+   (rcmpl (:%l x8632::nargs) (:$l (:apply ash n x8632::fixnumshift))))
   (jbe.pt :ok)
   (uuo-error-too-many-args)
@@ -242,5 +255,8 @@
 (define-x8632-vinsn default-1-arg (()
                                    ((min :u16const)))
-  (rcmpw (:%w x8632::nargs) (:$w (:apply ash min x8632::word-shift)))
+  ((:pred < min 32)
+   (rcmpl (:%l x8632::nargs) (:$b (:apply ash min x8632::fixnumshift))))
+  ((:pred >= min 32)
+   (rcmpl (:%l x8632::nargs) (:$l (:apply ash min x8632::fixnumshift))))
   (jne :done)
   ((:pred >= min 2)
@@ -253,5 +269,8 @@
 (define-x8632-vinsn default-2-args (()
 				    ((min :u16const)))
-  (rcmpw (:%w x8632::nargs ) (:$w (:apply ash (:apply 1+ min) x8632::word-shift)))
+  ((:pred < (:apply 1+ min) 32)
+   (rcmpl (:%l x8632::nargs) (:$b (:apply ash (:apply 1+ min) x8632::fixnumshift))))
+  ((:pred >= (:apply 1+ min) 32)
+   (rcmpl (:%l x8632::nargs) (:$l (:apply ash (:apply 1+ min) x8632::fixnumshift))))
   (ja :done)
   (je :one)
@@ -275,11 +294,17 @@
                                        ((n :u16const))
                                        ((temp :imm)))
-  (rcmpw (:%w x8632::nargs) (:$w (:apply ash n x8632::word-shift)))
-  (movw (:%w x8632::nargs) (:%w temp))
+  ((:pred < n 32)
+   (rcmpl (:%l x8632::nargs) (:$b (:apply ash n x8632::fixnumshift))))
+  ((:pred >= n 32)
+   (rcmpl (:%l x8632::nargs) (:$l (:apply ash n x8632::fixnumshift))))
+  (movl (:%l x8632::nargs) (:%l temp))
   (jae :done)
   :loop
-  (addw (:$w x8632::fixnumone) (:%w temp))
+  (addl (:$b x8632::fixnumone) (:%l temp))
   (pushl (:$l x8632::nil-value))
-  (cmpw (:$w (:apply ash n x8632::word-shift)) (:%w temp))
+  ((:pred < n 32)
+   (cmpl (:$b (:apply ash n x8632::fixnumshift)) (:%l temp)))
+  ((:pred >= n 32)
+   (cmpl (:$l (:apply ash n x8632::fixnumshift)) (:%l temp)))
   (jne :loop)
   :done)
@@ -299,5 +324,5 @@
                                                           ()
                                                           ((temp :u32)))
-  (movzwl (:%w x8632::nargs) (:%l temp))
+  (movl (:%l x8632::nargs) (:%l temp))
   (subl (:$b (* $numx8632argregs x8632::node-size)) (:%l temp))
   (jle :push)
@@ -316,5 +341,5 @@
                                                 ()
                                                 ((temp :u32)))
-  (movzwl (:%w x8632::nargs) (:%l temp))
+  (movl (:%l x8632::nargs) (:%l temp))
   (subl (:$b (* $numx8632argregs x8632::node-size)) (:%l temp))
   (movl (:%l x8632::ebp) (:@ x8632::node-size (:%l x8632::esp) (:%l temp)))
@@ -454,11 +479,11 @@
 (define-x8632-vinsn trap-unless-cons (()
 				      ((object :lisp))
-				      ((tag :u16)))
-  ;; check for NIL
+				      ((tag :u8)))
+  ;; special check for NIL (which is a distinguished CONS on x8632)
   (cmpl (:$l x8632::nil-value) (:%l object))
   (je.pn :bad)
-  (movw (:%w object) (:%w tag))
-  (andw (:$w x8632::fulltagmask) (:%w tag))
-  (cmpw (:$w x8632::fulltag-cons) (:%w tag))
+  (movl (:%l object) (:%l tag))
+  (andl (:$b x8632::fulltagmask) (:%l tag))
+  (cmpl (:$b x8632::fulltag-cons) (:%l tag))
   (je.pt :ok)
   :bad
@@ -468,8 +493,8 @@
 (define-x8632-vinsn trap-unless-uvector (()
                                          ((object :lisp))
-                                         ((tag :u16)))
-  (movw (:%w object) (:%w tag))
-  (andw (:$w x8632::tagmask) (:%w tag))
-  (cmpw (:$w x8632::tag-misc) (:%w tag))
+                                         ((tag :u8)))
+  (movl (:%l object) (:%l tag))
+  (andl (:$b x8632::tagmask) (:%l tag))
+  (cmpl (:$b x8632::tag-misc) (:%l tag))
   (jz.pt :ok)
   (uuo-error-reg-not-tag (:%l object) (:$ub x8632::tag-misc))
@@ -477,6 +502,9 @@
 
 (define-x8632-vinsn trap-unless-character (()
-                                              ((object :lisp)))
-  (cmpw (:$w x8632::subtag-character) (:%w object))
+					   ((object :lisp))
+					   ((tag :u8)))
+  ;; xxx can't be sure that object will be in a byte-accessible register
+  (movl (:%l object) (:%l tag))
+  (cmpb (:$b x8632::subtag-character) (:%b tag))
   (je.pt :ok)
   (uuo-error-reg-not-tag (:%l object) (:$ub x8632::subtag-character))
@@ -486,5 +514,5 @@
                                         ((object :lisp))
                                         ())
-  (testw (:$w x8632::tagmask) (:%w object))
+  (testl (:$l x8632::tagmask) (:%l object))
   (je.pt :ok)
   (uuo-error-reg-not-fixnum (:%l object))
@@ -493,5 +521,5 @@
 (define-x8632-vinsn set-flags-from-lisptag (()
                                             ((reg :lisp)))
-  (testw (:$w x8632::tagmask) (:%w reg)))
+  (testl (:$l x8632::tagmask) (:%l reg)))
 
 (define-x8632-vinsn trap-unless-typecode= (()
@@ -517,40 +545,43 @@
 (define-x8632-vinsn trap-unless-single-float (()
                                               ((object :lisp))
-                                              ((tag :u16)))
-  (movw (:%w object) (:%w tag))
-  (andw (:$w x8632::tagmask) (:%w tag))
-  (cmpw (:$w x8632::tag-misc) (:%w tag))
+                                              ((tag :u8)))
+  (movl (:%l object) (:%l tag))
+  (andl (:$b x8632::tagmask) (:%l tag))
+  (cmpl (:$b x8632::tag-misc) (:%l tag))
   (jne :have-tag)
-  (movw (:@ x8632::misc-subtag-offset (:%l object)) (:%w tag))
+  ;; xxx tag might not be byte-accessible
+  (movb (:@ x8632::misc-subtag-offset (:%l object)) (:%b tag))
   :have-tag
-  (cmpw (:$w x8632::subtag-single-float) (:%w tag))
+  (cmpl (:$b x8632::subtag-single-float) (:%l tag))
   (je.pt :ok)
-  (uuo-error-reg-not-tag (:%w object) (:$ub x8632::subtag-single-float))
+  (uuo-error-reg-not-tag (:%l object) (:$ub x8632::subtag-single-float))
   :ok)
 
 (define-x8632-vinsn trap-unless-double-float (()
                                               ((object :lisp))
-                                              ((tag :u16)))
-  (movw (:%w object) (:%w tag))
-  (andw (:$w x8632::tagmask) (:%w tag))
-  (cmpw (:$w x8632::tag-misc) (:%w tag))
+                                              ((tag :u8)))
+  (movl (:%l object) (:%l tag))
+  (andl (:$b x8632::tagmask) (:%l tag))
+  (cmpl (:$b x8632::tag-misc) (:%l tag))
   (jne :have-tag)
-  (movw (:@ x8632::misc-subtag-offset (:%l object)) (:%w tag))
+  ;; xxx tag might not be byte-accessible
+  (movb (:@ x8632::misc-subtag-offset (:%l object)) (:%b tag))
   :have-tag
-  (cmpw (:$w x8632::subtag-double-float) (:%w tag))
+  (cmpl (:$b x8632::subtag-double-float) (:%l tag))
   (je.pt :ok)
-  (uuo-error-reg-not-tag (:%w object) (:$ub x8632::subtag-double-float))
+  (uuo-error-reg-not-tag (:%l object) (:$ub x8632::subtag-double-float))
   :ok)
 
 (define-x8632-vinsn trap-unless-macptr (()
                                         ((object :lisp))
-                                        ((tag :u16)))
-  (movw (:%w object) (:%w tag))
-  (andw (:$w x8632::tagmask) (:%w tag))
-  (cmpw (:$w x8632::tag-misc) (:%w tag))
+                                        ((tag :u8)))
+  (movl (:%l object) (:%l tag))
+  (andl (:$b x8632::tagmask) (:%l tag))
+  (cmpl (:$b x8632::tag-misc) (:%l tag))
   (jne :have-tag)
-  (movw (:@ x8632::misc-subtag-offset (:%l object)) (:%w tag))
+  ;; xxx tag might not be byte-accessible
+  (movb (:@ x8632::misc-subtag-offset (:%l object)) (:%b tag))
   :have-tag
-  (cmpw (:$w x8632::subtag-macptr) (:%w tag))
+  (cmpl (:$b x8632::subtag-macptr) (:%l tag))
   (je.pt :ok)
   (uuo-error-reg-not-tag (:%l object) (:$ub x8632::subtag-macptr))
@@ -630,16 +661,30 @@
 (define-x8632-vinsn extract-tag-fixnum (((tag :imm))
 					((object :lisp)))
-  (leal (:@ (:%l object) 4) (:%l tag))
-  (andw (:$w (ash x8632::tagmask x8632::fixnumshift)) (:%w tag)))
+  ((:pred =
+	  (:apply %hard-regspec-value tag)
+	  (:apply %hard-regspec-value object))
+   (shll (:$ub x8632::fixnumshift) (:%l object)))
+  ((:not (:pred =
+		(:apply %hard-regspec-value tag)
+		(:apply %hard-regspec-value object)))
+   (imull (:$b x8632::fixnumone) (:%l object) (:%l tag)))
+  (andl (:$b (ash x8632::tagmask x8632::fixnumshift)) (:%l tag)))
 
 (define-x8632-vinsn extract-fulltag (((tag :u8))
                                  ((object :lisp)))
   (movl (:%l object) (:%l tag))
-  (andw (:$w x8632::fulltagmask) (:%w tag)))
+  (andl (:$b x8632::fulltagmask) (:%l tag)))
 
 (define-x8632-vinsn extract-fulltag-fixnum (((tag :imm))
                                             ((object :lisp)))
-  (leal (:@ (:%l object) 4) (:%l tag))
-  (andw (:$w (ash x8632::fulltagmask x8632::fixnumshift)) (:%w tag)))
+  ((:pred =
+	  (:apply %hard-regspec-value tag)
+	  (:apply %hard-regspec-value object))
+   (shll (:$ub x8632::fixnumshift) (:%l object)))
+  ((:not (:pred =
+		(:apply %hard-regspec-value tag)
+		(:apply %hard-regspec-value object)))
+   (imull (:$b x8632::fixnumone) (:%l object) (:%l tag)))
+  (andl (:$b (ash x8632::fulltagmask x8632::fixnumshift)) (:%l tag)))
 
 (define-x8632-vinsn extract-typecode (((tag :imm))
@@ -752,5 +797,5 @@
   (cmpl (:%l src) (:%l dest))
   (jne.pn :bad)
-  (testw (:$w x8632::fixnummask) (:%w dest))
+  (testl (:$l x8632::fixnummask) (:%l dest))
   (jne.pn :bad)
   (sarl (:$ub x8632::fixnumshift) (:%l dest))
@@ -781,5 +826,5 @@
   (cmpl (:%l src) (:%l dest))
   (jne.pn :bad)
-  (testw (:$w x8632::fixnummask) (:%w dest))
+  (testl (:$l x8632::fixnummask) (:%l dest))
   (je.pt :got-it)
   :bad
@@ -803,11 +848,11 @@
   (jmp :done)
   :maybe-bignum
-  (andw (:$w x8632::tagmask) (:%w dest))
-  (cmpw (:$w x8632::tag-misc) (:%w dest))
+  (andl (:$b x8632::tagmask) (:%l dest))
+  (cmpl (:$b x8632::tag-misc) (:%l dest))
   (jne :have-tag)
-  (movw (:@ x8632::misc-subtag-offset (:%l src)) (:%w dest))
-  (andw (:$w #xff) (:%w dest))
+  (movb (:@ x8632::misc-subtag-offset (:%l src)) (:%b dest))
+  (andl (:$l #xff) (:%l dest))
   :have-tag
-  (cmpw (:$w x8632::subtag-bignum) (:%w dest))
+  (cmpl (:$b x8632::subtag-bignum) (:%l dest))
   (jne :bad)
   (movl (:@ x8632::misc-header-offset (:%l src)) (:%l dest))
@@ -834,10 +879,10 @@
   (sarl (:$ub x8632::fixnumshift) (:%l dest))
   ;; Was it a fixnum ?
-  (testw (:$w x8632::fixnummask) (:%w src))
+  (testl (:$l x8632::fixnummask) (:%l src))
   (je :done)
   ;; May be a 2-digit bignum
-  (movw (:%w src) (:%w dest))
-  (andw (:$w x8632::tagmask) (:%w dest))
-  (cmpw (:$w x8632::tag-misc) (:%w dest))
+  (movl (:%l src) (:%l dest))
+  (andl (:$b x8632::tagmask) (:%l dest))
+  (cmpl (:$b x8632::tag-misc) (:%l dest))
   (jne :bad)
   (cmpl (:$l x8632::two-digit-bignum-header) (:@ x8632::misc-header-offset (:%l src)))
@@ -1120,6 +1165,6 @@
 
 (define-x8632-vinsn (push-argregs :push :node :vsp) (()
-                                                      ())
-  (rcmpw (:%w x8632::nargs) (:$w (* 1 x8632::node-size)))
+						     ())
+  (rcmpl (:%l x8632::nargs) (:$b (* 1 x8632::node-size)))
   (jb :done)
   (je :one)
@@ -1132,5 +1177,5 @@
                                                          ((max :u32const)))
   ((:pred >= max 2)
-   (rcmpw (:%w x8632::nargs) (:$w (* 1 x8632::node-size)))
+   (rcmpl (:%l x8632::nargs) (:$b (* 1 x8632::node-size)))
    (jb :done)
    (je :one)
@@ -1140,5 +1185,5 @@
    :done)
   ((:pred = max 1)
-   (testw (:%w x8632::nargs) (:%w x8632::nargs))
+   (testl (:%l x8632::nargs) (:%l x8632::nargs))
    (je :done)
    (pushl (:%l x8632::arg_z))
@@ -1322,18 +1367,17 @@
 (define-x8632-vinsn fitvals (()
                              ((n :u16const))
-                             ((imm :u16)))
+                             ((imm :u32)))
   ((:pred = n 0)
    (xorl (:%l imm) (:%l imm)))
   ((:not (:pred = n 0))
-   (movw (:$w (:apply ash n x8632::fixnumshift)) (:%w imm)))
-  (subw (:%w x8632::nargs) (:%w imm))
+   (movl (:$l (:apply ash n x8632::fixnumshift)) (:%l imm)))
+  (subl (:%l x8632::nargs) (:%l imm))
   (jae :push-more)
-  (movswl (:%w imm) (:%l imm))
   (subl (:%l imm) (:%l x8632::esp))
   (jmp :done)
   :push-loop
   (pushl (:$l x8632::nil-value))
-  (addw (:$b x8632::node-size) (:%w x8632::nargs))
-  (subw (:$b x8632::node-size) (:%w imm))
+  (addl (:$b x8632::node-size) (:%l x8632::nargs))
+  (subl (:$b x8632::node-size) (:%l imm))
   :push-more
   (jne :push-loop)
@@ -2945,5 +2989,5 @@
                                   ()
                                   ((tag :u8)))
-  (pushl (:%l x8632::nargs.l))
+  (pushl (:%l x8632::nargs))
   (movl (:%l x8632::temp0) (:%l tag))
   ((:pred = (:apply %hard-regspec-value tag) x8632::eax)
@@ -2962,5 +3006,5 @@
   (jne :bad)
   :go
-  (popl (:%l x8632::nargs.l))
+  (popl (:%l x8632::nargs))
   (jmp (:%l x8632::xfn))
   :bad
@@ -3074,5 +3118,5 @@
    (pushl (:%l x8632::arg_z)))
   ((:pred = min-fixed 1)                ; at least one arg
-   (rcmpw (:%w x8632::nargs) (:$w (ash 1 x8632::word-shift)))
+   (rcmpl (:%l x8632::nargs) (:$b (ash 1 x8632::word-shift)))
    (je :z1)				;skip arg_y if exactly 1
    (pushl (:%l x8632::arg_y))
@@ -3080,5 +3124,5 @@
    (pushl (:%l x8632::arg_z)))
   ((:pred = min-fixed 0)
-   (rcmpw (:%w x8632::nargs) (:$w (ash 1 x8632::word-shift)))
+   (rcmpl (:%l x8632::nargs) (:$b (ash 1 x8632::word-shift)))
    (je :z0)				;exactly one
    (jl :none)				;none
@@ -3089,5 +3133,4 @@
    :none
    )
-  (movzwl (:%w x8632::nargs) (:%l x8632::nargs))
   ((:not (:pred = min-fixed 0))
    (leal (:@ (:apply - (:apply ash min-fixed x8632::word-shift)) (:%l x8632::nargs))
@@ -3160,7 +3203,7 @@
 (define-x8632-vinsn pop-argument-registers (()
                                             ())
-  (testw (:%w x8632::nargs) (:%w x8632::nargs))
+  (testl (:%l x8632::nargs) (:%l x8632::nargs))
   (je :done)
-  (rcmpw (:%w x8632::nargs) (:$w (ash 1 x8632::word-shift)))
+  (rcmpl (:%l x8632::nargs) (:$l (ash 1 x8632::word-shift)))
   (popl (:%l x8632::arg_z))
   (je :done)
@@ -3187,8 +3230,4 @@
 					   (index :s32)))
   (movss (:@ (:%l src) (:%l index)) (:%xmm dest)))
-
-(define-x8632-vinsn zero-extend-nargs (()
-                                       ())
-  (movzwl (:%w x8632::nargs) (:%l x8632::nargs)))
 
 (define-x8632-vinsn load-adl (()
@@ -3333,5 +3372,4 @@
                                ()
                                ((temp :imm)))
-  (movzwl (:%w x8632::nargs) (:%l x8632::nargs))
   (leal (:@ (:%l x8632::esp) (:%l x8632::nargs)) (:%l temp))
   (subl (:@ (:%l temp)) (:%l x8632::nargs))
@@ -3454,16 +3492,18 @@
 				 ((nfixed :s16const)))
   ((:pred > nfixed 0)
-   (addw (:$w (:apply - (:apply ash nfixed x8632::word-shift))) (:%w x8632::nargs))))
-
+   ((:pred < nfixed 32)
+    (subl (:$b (:apply ash nfixed x8632::word-shift)) (:%l x8632::nargs)))
+   ((:pred >= nfixed 32)
+    (subl (:$l (:apply ash nfixed x8632::word-shift)) (:%l x8632::nargs)))))
 
 ;; num-opt in arg_z
 (define-x8632-vinsn opt-supplied-p (()
                                     ())
-  (subw (:%w x8632::nargs) (:%w x8632::arg_z))
+  (subl (:%l x8632::nargs) (:%l x8632::arg_z))
   (jmp :push-t-test)
   :push-t-loop
   (pushl (:$l x8632::t-value))
   :push-t-test
-  (subw (:$w x8632::node-size) (:%w x8632::nargs))
+  (subl (:$b x8632::node-size) (:%l x8632::nargs))
   (jge :push-t-loop)
   (jmp :push-nil-test)
@@ -3471,10 +3511,10 @@
   (pushl (:$l x8632::nil-value))
   :push-nil-test
-  (subw (:$w x8632::node-size) (:%w x8632::arg_z))
+  (subl (:$b x8632::node-size) (:%l x8632::arg_z))
   (jge :push-nil-loop))
 
 (define-x8632-vinsn one-opt-supplied-p (()
                                         ())
-  (testw (:%w x8632::nargs) (:%w x8632::nargs))
+  (testl (:%l x8632::nargs) (:%l x8632::nargs))
   (je :one)
   (pushl (:$l x8632::nil-value))
@@ -3488,7 +3528,7 @@
                                         ())
   ;; note that nargs is imm0
-  (rcmpw (:%w x8632::nargs) (:$w (:apply ash 2 x8632::word-shift)))
+  (rcmpl (:%l x8632::nargs) (:$b (:apply ash 2 x8632::word-shift)))
   (jge :two)
-  (rcmpw (:%w x8632::nargs) (:$w (:apply ash 1 x8632::word-shift)))
+  (rcmpl (:%l x8632::nargs) (:$b (:apply ash 1 x8632::word-shift)))
   (je :one)
   ;; none
