Unbox exp on complex numbers.
This commit is contained in:
parent
c68b464fcd
commit
c4613cf9ab
27
collects/tests/typed-racket/optimizer/tests/unboxed-exp.rkt
Normal file
27
collects/tests/typed-racket/optimizer/tests/unboxed-exp.rkt
Normal file
|
@ -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)
|
|
@ -246,6 +246,20 @@
|
||||||
(unsafe-fl+ (unsafe-fl* c.real-binding c.real-binding)
|
(unsafe-fl+ (unsafe-fl* c.real-binding c.real-binding)
|
||||||
(unsafe-fl* c.imag-binding c.imag-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)))
|
(pattern (#%plain-app (~and op (~or (~literal real-part) (~literal unsafe-flreal-part)))
|
||||||
c:unboxed-float-complex-opt-expr)
|
c:unboxed-float-complex-opt-expr)
|
||||||
#:with real-binding #'c.real-binding
|
#:with real-binding #'c.real-binding
|
||||||
|
@ -398,7 +412,7 @@
|
||||||
|
|
||||||
(define-syntax-class float-complex-op
|
(define-syntax-class float-complex-op
|
||||||
#:commit
|
#: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
|
(define-syntax-class float-complex->float-op
|
||||||
#:commit
|
#:commit
|
||||||
|
|
Loading…
Reference in New Issue
Block a user