Optimize expt on floats.

This commit is contained in:
Vincent St-Amour 2014-04-23 12:38:01 -04:00
parent 2adc374fc6
commit 4d36910026
4 changed files with 17 additions and 2 deletions

View File

@ -15,7 +15,7 @@
(mk-unsafe-tbl generic "fl~a" "unsafe-fl~a"))
(define binary-float-ops
(mk-float-tbl (list #'+ #'- #'* #'/ #'min #'max)))
(mk-float-tbl (list #'+ #'- #'* #'/ #'min #'max #'expt)))
(define binary-float-comps
(dict-set*
(mk-float-tbl (list #'= #'<= #'< #'> #'>=))

View File

@ -4,6 +4,8 @@ TR info: fixnum.rkt 12:0 (fx* (values (ann x Index)) (values (ann y Index))) --
TR info: fixnum.rkt 15:0 (fx+ (+ 300 301) (+ 301 302)) -- non-optimized fixnum op
TR info: fixnum.rkt 16:0 (fxquotient -4 -5) -- non-optimized fixnum op
TR info: fixnum.rkt 44:28 (- 1 (expt 2 (- (system-type (quote word)) 2))) -- possible exact real arith
TR info: fixnum.rkt 44:33 (expt 2 (- (system-type (quote word)) 2)) -- possible exact real arith
TR info: fixnum.rkt 45:28 (expt 2 (- (system-type (quote word)) 2)) -- possible exact real arith
TR missed opt: fixnum.rkt 10:0 (+ (ann z Fixnum) 234) -- out of fixnum range
TR missed opt: fixnum.rkt 11:0 (* (ann x Index) (ann y Index)) -- out of fixnum range
TR missed opt: fixnum.rkt 14:0 (+ (+ 300 301) (+ 301 302)) -- out of fixnum range

View File

@ -1,10 +1,14 @@
#;#;
#<<END
TR missed opt: exact-inexact.rkt 8:16 (expt 1.0f0 2.0f0) -- all args float-arg-expr, result not Float -- caused by: 8:22 1.0f0, 8:28 2.0f0
TR missed opt: exact-inexact.rkt 9:21 (expt 1.0f0 2.0f0) -- all args float-arg-expr, result not Float -- caused by: 9:27 1.0f0, 9:33 2.0f0
TR opt: exact-inexact.rkt 2:0 (exact->inexact (expt 10 100)) -- int to float
TR opt: exact-inexact.rkt 3:0 (round (exact->inexact (expt 2.3 3.2))) -- unary float
TR opt: exact-inexact.rkt 3:23 (expt 2.3 3.2) -- binary float
TR opt: exact-inexact.rkt 3:7 (exact->inexact (expt 2.3 3.2)) -- float to float
TR opt: exact-inexact.rkt 4:0 (real->double-flonum (expt 10 100)) -- int to float
TR opt: exact-inexact.rkt 5:0 (round (real->double-flonum (expt 2.3 3.2))) -- unary float
TR opt: exact-inexact.rkt 5:28 (expt 2.3 3.2) -- binary float
TR opt: exact-inexact.rkt 5:7 (real->double-flonum (expt 2.3 3.2)) -- float to float
TR opt: exact-inexact.rkt 8:0 (exact->inexact (expt 1.0f0 2.0f0)) -- single-float to single-float
TR opt: exact-inexact.rkt 9:0 (real->single-flonum (expt 1.0f0 2.0f0)) -- single-float to single-float

View File

@ -1,9 +1,15 @@
#;#;
#<<END
TR missed opt: expt.rkt 6:13 (expt (sin 0.25) 1.0) -- unexpected complex type
TR missed opt: expt.rkt 9:0 (expt -2.0 0.5) -- unexpected complex type
TR opt: expt.rkt 6:19 (sin 0.25) -- unary float
TR opt: expt.rkt 8:0 (expt 2.0 3.0) -- binary float
END
#<<END
8.0
8.659560562354934e-17+1.4142135623730951i
END
""
#lang typed/racket
#reader tests/typed-racket/optimizer/reset-port
@ -12,3 +18,6 @@ END
;; this let to incorrect optimization
(define (crash)
(real-part (expt (sin 0.25) 1.0)))
(expt 2.0 3.0)
(expt -2.0 0.5) ; not a valid optimization, returns a complex