Changeset 15863


Ignore:
Timestamp:
Jul 15, 2013, 9:48:56 AM (7 years ago)
Author:
gb
Message:

Rewrite NUMCMP acode.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/acode-rewrite/source/compiler/acode-rewrite.lisp

    r15805 r15863  
    671671    (rewrite-acode-form callable))
    672672  (dolist (form formlist) (rewrite-acode-form form)))
     673
     674(def-acode-rewrite acode-rewrite-numcmp numcmp asserted-type (&whole w cc num1 num2)
     675  (let* ((ccval (cadr cc))
     676         (fn (case ccval
     677               (:lt '<)
     678               (:le '<=)
     679               (:eq '=)
     680               (:ne '/=)
     681               (:ge '>=)
     682               (:gt '>))))
     683    (rewrite-acode-form num1)
     684    (rewrite-acode-form num2)
     685    (multiple-value-bind (v1 c1) (acode-constant-p num1)
     686      (multiple-value-bind (v2 c2) (acode-constant-p num2)
     687        (multiple-value-bind (constval error)
     688            (if (and c1 c2)
     689              (ignore-errors (funcall fn v1 v2))
     690              (values nil t))
     691          (if (not error)
     692            (acode-rewrite-as-constant-ref w constval)
     693            (let* ((op (acode-operator w)))
     694              (or (acode-strength-reduce-binop w num1 num2 *nx-target-fixnum-type* op (%nx1-operator %i<>))
     695                  (acode-strength-reduce-binop w num1 num2 *nx-target-natural-type* op (%nx1-operator %natural<>))
     696                  (acode-strength-reduce-binop w num1 num2 'double-float op (%nx1-operator double-float-compare))
     697                  (acode-strength-reduce-binop w num1 num2 'single-float op (%nx1-operator short-float-compare))
     698                  ;; Could try contagion here
     699                  ))))))))
Note: See TracChangeset for help on using the changeset viewer.