Commit 136902ba authored by Frode Vatvedt Fjeld's avatar Frode Vatvedt Fjeld
Browse files

Fix constant-folding for logand.

parent 9927d909
Loading
Loading
Loading
Loading
+24 −18
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@
;;;; Author:        Frode Vatvedt Fjeld <frodef@acm.org>
;;;; Created at:    Sat Jul 17 13:42:46 2004
;;;;                
;;;; $Id: arithmetic-macros.lisp,v 1.21 2008/03/17 17:24:42 ffjeld Exp $
;;;; $Id: arithmetic-macros.lisp,v 1.22 2008/04/21 19:29:17 ffjeld Exp $
;;;;                
;;;;------------------------------------------------------------------

@@ -305,10 +305,15 @@
				      finally (return (if (= -1 folded-constant)
							  non-constants
							(cons folded-constant non-constants))))))
    (case (length constant-folded-integers)
      (0 0)
      (1 (first constant-folded-integers))
      (2 (cond
    (cond
      ((null constant-folded-integers)
       0)
      ((null (rest constant-folded-integers))
       (first constant-folded-integers))
      ((eql 0 (first constant-folded-integers))
       `(progn ,@(rest constant-folded-integers) 0))
      ((null (cddr constant-folded-integers))
       (cond
	 ((typep (first constant-folded-integers)
		 '(unsigned-byte 32))
	  (let ((x (first constant-folded-integers)))
@@ -320,7 +325,8 @@
	 (t `(no-macro-call logand
			    ,(first constant-folded-integers)
			    ,(second constant-folded-integers)))))
      (t `(logand (logand ,(first constant-folded-integers) ,(second constant-folded-integers))
      (t `(logand (logand ,(first constant-folded-integers)
			  ,(second constant-folded-integers))
		  ,@(cddr constant-folded-integers))))))

(define-compiler-macro logior (&whole form &rest integers &environment env)
@@ -410,7 +416,7 @@
   (t form)))

(define-compiler-macro ldb (&whole form &environment env bytespec integer)
  (let ((bytespec (movitz::movitz-macroexpand bytespec env)))
  (let ((bytespec (movitz-macroexpand bytespec env)))
    (if (not (and (consp bytespec) (eq 'byte (car bytespec))))
	form
      `(ldb%byte ,(second bytespec) ,(third bytespec) ,integer))))