X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler%2Fsrctran.lisp;h=c39aeff0f924d1594ec69c4bd9d03a826c35acc9;hb=43b1750ede8767928788b158399d3c5d2910855a;hp=c49fe9408083a3c7c473eafb2b276483839c09e4;hpb=23fe13b4d58313c1b988a948a219661486545d54;p=sbcl.git diff --git a/src/compiler/srctran.lisp b/src/compiler/srctran.lisp index c49fe94..c39aeff 100644 --- a/src/compiler/srctran.lisp +++ b/src/compiler/srctran.lisp @@ -3414,17 +3414,20 @@ (neq *empty-type* (type-intersection (specifier-type 'float) (lvar-type lvar)))) -(flet ((maybe-invert (op inverted x y) +(flet ((maybe-invert (node op inverted x y) ;; Don't invert if either argument can be a float (NaNs) - (if (or (maybe-float-lvar-p x) (maybe-float-lvar-p y)) - `(or (,op x y) (= x y)) - `(if (,inverted x y) nil t)))) - (deftransform >= ((x y) (number number) *) + (cond + ((or (maybe-float-lvar-p x) (maybe-float-lvar-p y)) + (delay-ir1-transform node :constraint) + `(or (,op x y) (= x y))) + (t + `(if (,inverted x y) nil t))))) + (deftransform >= ((x y) (number number) * :node node) "invert or open code" - (maybe-invert '> '< x y)) - (deftransform <= ((x y) (number number) *) + (maybe-invert node '> '< x y)) + (deftransform <= ((x y) (number number) * :node node) "invert or open code" - (maybe-invert '< '> x y))) + (maybe-invert node '< '> x y))) ;;; See whether we can statically determine (< X Y) using type ;;; information. If X's high bound is < Y's low, then X < Y. @@ -3494,15 +3497,16 @@ ;;; negated test as appropriate. If it is a degenerate one-arg call, ;;; then we transform to code that returns true. Otherwise, we bind ;;; all the arguments and expand into a bunch of IFs. -(declaim (ftype (function (symbol list boolean t) *) multi-compare)) -(defun multi-compare (predicate args not-p type) +(defun multi-compare (predicate args not-p type &optional force-two-arg-p) (let ((nargs (length args))) (cond ((< nargs 1) (values nil t)) ((= nargs 1) `(progn (the ,type ,@args) t)) ((= nargs 2) (if not-p `(if (,predicate ,(first args) ,(second args)) nil t) - (values nil t))) + (if force-two-arg-p + `(,predicate ,(first args) ,(second args)) + (values nil t)))) (t (do* ((i (1- nargs) (1- i)) (last nil current) @@ -3540,15 +3544,15 @@ 'character)) (define-source-transform char-equal (&rest args) - (multi-compare 'char-equal args nil 'character)) + (multi-compare 'sb!impl::two-arg-char-equal args nil 'character t)) (define-source-transform char-lessp (&rest args) - (multi-compare 'char-lessp args nil 'character)) + (multi-compare 'sb!impl::two-arg-char-lessp args nil 'character t)) (define-source-transform char-greaterp (&rest args) - (multi-compare 'char-greaterp args nil 'character)) + (multi-compare 'sb!impl::two-arg-char-greaterp args nil 'character t)) (define-source-transform char-not-greaterp (&rest args) - (multi-compare 'char-greaterp args t 'character)) + (multi-compare 'sb!impl::two-arg-char-greaterp args t 'character t)) (define-source-transform char-not-lessp (&rest args) - (multi-compare 'char-lessp args t 'character)) + (multi-compare 'sb!impl::two-arg-char-lessp args t 'character t)) ;;; This function does source transformation of N-arg inequality ;;; functions such as /=. This is similar to MULTI-COMPARE in the <3