Changeset 11641


Ignore:
Timestamp:
02/08/09 10:06:19 (12 years ago)
Author:
ehuelsmann
Message:

Integer bounds derivation for MIN and MAX.
Compilation of (*) -> 1 (fixes ANSI test '*.1').
Better type derivation for (+).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/compiler-pass2.lisp

    r11640 r11641  
    63046304(defvar zero-integer-type (%make-integer-type 0 0)
    63056305  "Integer type representing the 0 (zero)
    6306 value for use with derive-type-minus.")
     6306value for use with derive-type-minus and derive-type-plus.")
    63076307
    63086308(define-int-bounds-derivation - (low1 high1 low2 high2)
     
    63326332  (let ((op (car form))
    63336333        (args (cdr form)))
    6334     (flet ((combine (x y)
    6335              (derive-type-numeric-op op x y)))
    6336       (reduce #'combine (cdr args) :key #'derive-compiler-type
    6337               :initial-value (derive-compiler-type (car args))))))
     6334    (if (null args)
     6335        zero-integer-type
     6336        (flet ((combine (x y)
     6337                 (derive-type-numeric-op op x y)))
     6338          (reduce #'combine (cdr args) :key #'derive-compiler-type
     6339                  :initial-value (derive-compiler-type (car args)))))))
    63386340
    63396341(define-int-bounds-derivation * (low1 high1 low2 high2)
     
    63526354         (values (* low1 low2) (* high1 high2)))))
    63536355
     6356(defvar one-integer-type (%make-integer-type 1 1)
     6357  "Integer type representing the value 1 (one)
     6358for use with derive-type-times.")
     6359
    63546360(defun derive-type-times (form)
    63556361  (let ((op (car form))
    63566362        (args (cdr form)))
    6357     (flet ((combine (x y)
    6358              (derive-type-numeric-op op x y)))
    6359       (reduce #'combine (cdr args) :key #'derive-compiler-type
    6360               :initial-value (derive-compiler-type (car args))))))
     6363    (if (null args)
     6364        one-integer-type
     6365        (flet ((combine (x y)
     6366                 (derive-type-numeric-op op x y)))
     6367          (reduce #'combine (cdr args) :key #'derive-compiler-type
     6368                  :initial-value (derive-compiler-type (car args)))))))
     6369
     6370(define-int-bounds-derivation max (low1 low2 high1 high2)
     6371  (values (or (when (and low1 low2) (max low1 low2)) low1 low2)
     6372          (or (when (and high1 high2) (max high1 high2)) high1 high2)))
    63616373
    63626374(declaim (ftype (function (t) t) derive-type-max))
     
    63686380      (reduce #'combine (cdr args) :key #'derive-compiler-type
    63696381              :initial-value (derive-compiler-type (car args))))))
     6382
     6383(define-int-bounds-derivation min (low1 high1 low2 high2)
     6384  (values (or (when (and low1 low2) (min low1 low2)) low1 low2)
     6385          (or (when (and high1 high2) (min high1 high2)) high1 hig2)))
    63706386
    63716387(defknown derive-type-min (t) t)
     
    67006716(defun p2-times (form target representation)
    67016717  (case (length form)
     6718    (1 (compile-constant 1 target representation))
    67026719    (2 (compile-form (cadr form) target representation))
    67036720    (3
Note: See TracChangeset for help on using the changeset viewer.