Report missed optimizations for unary float operations.

This commit is contained in:
Vincent St-Amour 2011-06-02 17:28:14 -04:00
parent cc129adb39
commit 647ae4fe9a
3 changed files with 31 additions and 6 deletions

View File

@ -0,0 +1,18 @@
#;
(
unary-float.rkt 14:0 (#%app sin (quote 3.4)) -- unary, arg float-arg-expr, return type not Float
unary-float.rkt 15:0 (#%app sin (quote 3)) -- unary, arg float-arg-expr, return type not Float
unary-float.rkt 16:0 (#%app abs (quote 3.4)) -- unary, arg float-arg-expr, return type not Float
-0.2555411020268312
0.1411200080598672
3.4
3
)
#lang typed/racket
(sin (ann 3.4 Real))
(sin 3)
(abs (ann 3.4 Real))
(abs (ann 3 Integer)) ; stays within Integer, should not be reported

View File

@ -1,10 +1,11 @@
#; #;
( (
float-complex-sin.rkt 15:10 (#%app + (#%app sin (#%app * t (quote 6.28))) (quote 0.0+0.0i)) -- unboxed float complex float-complex-sin.rkt 16:10 (#%app + (#%app sin (#%app * t (quote 6.28))) (quote 0.0+0.0i)) -- unboxed float complex
float-complex-sin.rkt 15:11 + -- unboxed binary float complex float-complex-sin.rkt 16:11 + -- unboxed binary float complex
float-complex-sin.rkt 15:13 (#%app sin (#%app * t (quote 6.28))) -- float-coerce-expr in complex ops float-complex-sin.rkt 16:13 (#%app sin (#%app * t (quote 6.28))) -- float-coerce-expr in complex ops
float-complex-sin.rkt 15:18 (#%app * t (quote 6.28)) -- binary, args all float-arg-expr, return type not Float -- caused by: 15:21 t float-complex-sin.rkt 16:13 (#%app sin (#%app * t (quote 6.28))) -- unary, arg float-arg-expr, return type not Float
float-complex-sin.rkt 15:30 0.0+0.0i -- unboxed literal float-complex-sin.rkt 16:18 (#%app * t (quote 6.28)) -- binary, args all float-arg-expr, return type not Float -- caused by: 16:21 t
float-complex-sin.rkt 16:30 0.0+0.0i -- unboxed literal
-0.0031853017931379904+0.0i -0.0031853017931379904+0.0i
) )

View File

@ -77,7 +77,13 @@
(define-syntax-class float-opt-expr (define-syntax-class float-opt-expr
#:commit #:commit
(pattern (#%plain-app (~var op (float-op unary-float-ops)) f:float-arg-expr) (pattern (#%plain-app (~var op (float-op unary-float-ops)) f:float-arg-expr)
#:when (subtypeof? this-syntax -Flonum) #:when (let* ([safe-to-opt? (subtypeof? this-syntax -Flonum)]
[missed-optimization? (and (not safe-to-opt?)
(in-real-layer? this-syntax))])
(when missed-optimization?
(log-missed-optimization "unary, arg float-arg-expr, return type not Float"
this-syntax))
safe-to-opt?)
#:with opt #:with opt
(begin (log-optimization "unary float" #'op) (begin (log-optimization "unary float" #'op)
#'(op.unsafe f.opt))) #'(op.unsafe f.opt)))