diff --git a/collects/tests/typed-racket/optimizer/tests/unboxed-exp.rkt b/collects/tests/typed-racket/optimizer/tests/unboxed-exp.rkt new file mode 100644 index 0000000000..09e07d8d6a --- /dev/null +++ b/collects/tests/typed-racket/optimizer/tests/unboxed-exp.rkt @@ -0,0 +1,27 @@ +#; +( +TR opt: unboxed-exp.rkt 23:5 2.0+3.4i -- unboxed literal +TR opt: unboxed-exp.rkt 23:0 (exp 2.0+3.4i) -- unboxed unary float complex +TR opt: unboxed-exp.rkt 24:5 0.0+0.0i -- unboxed literal +TR opt: unboxed-exp.rkt 24:0 (exp 0.0+0.0i) -- unboxed unary float complex +TR opt: unboxed-exp.rkt 25:5 -12.2-4.7i -- unboxed literal +TR opt: unboxed-exp.rkt 25:0 (exp -12.2-4.7i) -- unboxed unary float complex +TR opt: unboxed-exp.rkt 26:5 12.2-4.7i -- unboxed literal +TR opt: unboxed-exp.rkt 26:0 (exp 12.2-4.7i) -- unboxed unary float complex +TR opt: unboxed-exp.rkt 27:5 -12.2+4.7i -- unboxed literal +TR opt: unboxed-exp.rkt 27:0 (exp -12.2+4.7i) -- unboxed unary float complex +-7.143726081314396-1.8882075384588168i +1.0+0.0i +-6.232062158151458e-08+5.030069557694479e-06i +-2462.731893583747+198773.89557926523i +-6.232062158151458e-08-5.030069557694479e-06i +) + +#lang typed/racket +#:optimize + +(exp 2.0+3.4i) +(exp 0.0+0.0i) +(exp -12.2-4.7i) +(exp 12.2-4.7i) +(exp -12.2+4.7i) diff --git a/collects/typed-racket/optimizer/float-complex.rkt b/collects/typed-racket/optimizer/float-complex.rkt index 283943ee5f..0ce34696ea 100644 --- a/collects/typed-racket/optimizer/float-complex.rkt +++ b/collects/typed-racket/optimizer/float-complex.rkt @@ -246,6 +246,20 @@ (unsafe-fl+ (unsafe-fl* c.real-binding c.real-binding) (unsafe-fl* c.imag-binding c.imag-binding))))))) + (pattern (#%plain-app (~and op (~literal exp)) c:unboxed-float-complex-opt-expr) + #:with real-binding (unboxed-gensym "unboxed-real-") + #:with imag-binding (unboxed-gensym "unboxed-imag-") + #:with scaling-factor (unboxed-gensym "unboxed-scaling-") + #:with (bindings ...) + (begin (log-optimization "unboxed unary float complex" + complex-unboxing-opt-msg + this-syntax) + (add-disappeared-use #'op) + #`(c.bindings ... + ((scaling-factor) (unsafe-flexp c.real-binding)) + ((real-binding) (unsafe-fl* (unsafe-flcos c.imag-binding) scaling-factor)) + ((imag-binding) (unsafe-fl* (unsafe-flsin c.imag-binding) scaling-factor))))) + (pattern (#%plain-app (~and op (~or (~literal real-part) (~literal unsafe-flreal-part))) c:unboxed-float-complex-opt-expr) #:with real-binding #'c.real-binding @@ -398,7 +412,7 @@ (define-syntax-class float-complex-op #:commit - (pattern (~or (~literal +) (~literal -) (~literal *) (~literal /) (~literal conjugate)))) + (pattern (~or (~literal +) (~literal -) (~literal *) (~literal /) (~literal conjugate) (~literal exp)))) (define-syntax-class float-complex->float-op #:commit