Raymond Toy pushed to branch issue-156-take-2-nan-comparison at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/compiler/srctran.lisp
    ... ... @@ -3537,6 +3537,11 @@
    3537 3537
     (deftransform > ((x y) (real real) * :when :both)
    
    3538 3538
       (ir1-transform-< y x x y '<))
    
    3539 3539
     
    
    3540
    +;;; Ir1-transform->=-helper -- Internal
    
    3541
    +;;;
    
    3542
    +;;; Derives the result type of the comparison X >= Y returning two
    
    3543
    +;;; values: the first true if X >= Y, and the second true if X < Y.
    
    3544
    +;;; This is the equivalent of ir1-transform-<-helper, but for >=.
    
    3540 3545
     #+(and x86)
    
    3541 3546
     (defun ir1-transform->=-helper (x y)
    
    3542 3547
       (flet ((maybe-convert (type)
    
    ... ... @@ -3558,34 +3563,33 @@
    3558 3563
     				      (interval-< x-arg y-arg)))))
    
    3559 3564
           (values definitely-true definitely-false))))
    
    3560 3565
     
    
    3566
    +;;; IR1-TRANSFORM->= -- Internal
    
    3567
    +;;;
    
    3568
    +;;;   Like IR1-TRANSFORM-< but for >=.  This is needed so that the
    
    3569
    +;;; compiler can statically determine (>= X Y) using type information.
    
    3561 3570
     #+(and x86)
    
    3562 3571
     (defun ir1-transform->= (x y first second inverse)
    
    3563
    -    (if (same-leaf-ref-p x y)
    
    3564
    -	't
    
    3565
    -	(multiple-value-bind (definitely-true definitely-false)
    
    3566
    -	    (ir1-transform->=-helper x y)
    
    3567
    -	  (cond (definitely-true
    
    3568
    -		    t)
    
    3569
    -		(definitely-false
    
    3570
    -		    nil)
    
    3571
    -		((and (constant-continuation-p first)
    
    3572
    -                      (not (constant-continuation-p second)))
    
    3573
    -		 #+nil
    
    3574
    -		 (format t "swapping ~A~%" inverse)
    
    3575
    -		 `(,inverse y x))
    
    3576
    -		(t
    
    3577
    -		 (give-up))))))
    
    3572
    +  ;; If the leaves are the same, the (>= X Y) is true.
    
    3573
    +  (if (same-leaf-ref-p x y)
    
    3574
    +      't
    
    3575
    +      (multiple-value-bind (definitely-true definitely-false)
    
    3576
    +	  (ir1-transform->=-helper x y)
    
    3577
    +	(cond (definitely-true
    
    3578
    +		  t)
    
    3579
    +	      (definitely-false
    
    3580
    +		  nil)
    
    3581
    +	      ((and (constant-continuation-p first)
    
    3582
    +                    (not (constant-continuation-p second)))
    
    3583
    +	       `(,inverse y x))
    
    3584
    +	      (t
    
    3585
    +	       (give-up))))))
    
    3578 3586
     
    
    3579 3587
     #+(and x86)
    
    3580 3588
     (deftransform <= ((x y) (real real) * :when :both)
    
    3581
    -  #+nli
    
    3582
    -  (format t "transform <=~%")
    
    3583 3589
       (ir1-transform->= y x x y '>=))
    
    3584 3590
     
    
    3585 3591
     #+(and  x86)
    
    3586 3592
     (deftransform >= ((x y) (real real) * :when :both)
    
    3587
    -  #+nil
    
    3588
    -  (format t "transform >=~%")
    
    3589 3593
       (ir1-transform->= x y x y '<=))
    
    3590 3594
     
    
    3591 3595
     
    
    ... ... @@ -3605,7 +3609,6 @@
    3605 3609
         ;; (<= x y) is the same as (not (> x y))
    
    3606 3610
         `(not (> x y)))
    
    3607 3611
     
    
    3608
    -  
    
    3609 3612
       (deftransform >= ((x y) (integer integer) * :when :both)
    
    3610 3613
         ;; (>= x y) is the same as (not (< x y))
    
    3611 3614
         `(not (< x y))))