Skip to content
Snippets Groups Projects
Commit 52d57db5 authored by ram's avatar ram
Browse files

Improved IR1-TRANFORM-< to expand to NIL in some interesting cases where the

types do intersect.  The old code was correct, but missed some opportunities.
parent 7f5b511d
No related branches found
No related tags found
No related merge requests found
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
;;; Scott Fahlman (FAHLMAN@CMUC). ;;; Scott Fahlman (FAHLMAN@CMUC).
;;; ********************************************************************** ;;; **********************************************************************
;;; ;;;
;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/srctran.lisp,v 1.8 1990/05/09 12:00:13 ram Exp $ ;;; $Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/srctran.lisp,v 1.9 1990/05/23 16:39:30 ram Exp $
;;; ;;;
;;; This file contains macro-like source transformations which convert ;;; This file contains macro-like source transformations which convert
;;; uses of certain functions into the canonical form desired within the ;;; uses of certain functions into the canonical form desired within the
...@@ -790,21 +790,25 @@ ...@@ -790,21 +790,25 @@
;;; IR1-TRANSFORM-< -- Internal ;;; IR1-TRANSFORM-< -- Internal
;;; ;;;
;;; See if we can statically determine (< X Y) using type information. If ;;; See if we can statically determine (< X Y) using type information. If
;;; the types don't intersect, then we can always determine the relationship. ;;; X's high bound is < Y's low, then X < Y. Similarly, if X's low is >= to
;;; < can only be true if X has a high bound and Y has a low bound, and X's ;;; Y's high, the X >= Y (so return NIL).
;;; high bound is < Y's low bound.
;;; ;;;
(defun ir1-transform-< (x y) (defun ir1-transform-< (x y)
(if (same-leaf-ref-p x y) (if (same-leaf-ref-p x y)
'nil 'nil
(let* ((x (numeric-type-or-lose x)) (let* ((x (numeric-type-or-lose x))
(x-lo (numeric-type-low x))
(x-hi (numeric-type-high x)) (x-hi (numeric-type-high x))
(y (numeric-type-or-lose y)) (y (numeric-type-or-lose y))
(y-lo (numeric-type-low y))) (y-lo (numeric-type-low y))
(when (types-intersect x y) (give-up)) (y-hi (numeric-type-high y)))
(if (and x-hi y-lo (< x-hi y-lo)) (cond ((and x-hi y-lo (< x-hi y-lo))
't 't)
'nil)))) ((and y-hi x-lo (>= x-lo y-hi))
'nil)
(t
(give-up))))))
(deftransform < ((x y) (integer integer)) (deftransform < ((x y) (integer integer))
(ir1-transform-< x y)) (ir1-transform-< x y))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment