Add missed optimizations for non complexs in complex arithmetic.
This commit is contained in:
parent
676be5de06
commit
78b9a8a360
|
@ -41,6 +41,13 @@
|
||||||
(log-opt opt-label "Complex number unboxing."))
|
(log-opt opt-label "Complex number unboxing."))
|
||||||
(define-syntax-rule (log-arity-raising-opt opt-label)
|
(define-syntax-rule (log-arity-raising-opt opt-label)
|
||||||
(log-opt opt-label arity-raising-opt-msg))
|
(log-opt opt-label arity-raising-opt-msg))
|
||||||
|
(define-syntax-rule (log-missed-complex-expr)
|
||||||
|
(log-missed-optimization
|
||||||
|
"Non complex value in complex arithmetic"
|
||||||
|
(string-append
|
||||||
|
"This expression has a non FloatComplex type and thus cannot "
|
||||||
|
"be promoted to unboxed arithmetic.")
|
||||||
|
this-syntax))
|
||||||
|
|
||||||
;; If a part is 0.0?
|
;; If a part is 0.0?
|
||||||
(define (0.0? stx)
|
(define (0.0? stx)
|
||||||
|
@ -240,7 +247,8 @@
|
||||||
(unsafe-fl* c.imag-binding c.imag-binding))))))
|
(unsafe-fl* c.imag-binding c.imag-binding))))))
|
||||||
|
|
||||||
(pattern (#%plain-app op:exp^ c:unboxed-float-complex-opt-expr)
|
(pattern (#%plain-app op:exp^ c:unboxed-float-complex-opt-expr)
|
||||||
#:when (subtypeof? this-syntax -FloatComplex)
|
#:when (or (subtypeof? this-syntax -FloatComplex)
|
||||||
|
(and (log-missed-complex-expr) #f))
|
||||||
#:with (real-binding imag-binding) (binding-names)
|
#:with (real-binding imag-binding) (binding-names)
|
||||||
#:with scaling-factor (generate-temporary "unboxed-scaling-")
|
#:with scaling-factor (generate-temporary "unboxed-scaling-")
|
||||||
#:do [(log-unboxing-opt "unboxed unary float complex")]
|
#:do [(log-unboxing-opt "unboxed unary float complex")]
|
||||||
|
@ -272,14 +280,16 @@
|
||||||
|
|
||||||
;; we can eliminate boxing that was introduced by the user
|
;; we can eliminate boxing that was introduced by the user
|
||||||
(pattern (#%plain-app op:make-rectangular^ real:float-arg-expr imag:float-arg-expr)
|
(pattern (#%plain-app op:make-rectangular^ real:float-arg-expr imag:float-arg-expr)
|
||||||
#:when (subtypeof? this-syntax -FloatComplex)
|
#:when (or (subtypeof? this-syntax -FloatComplex)
|
||||||
|
(and (log-missed-complex-expr) #f))
|
||||||
#:with (real-binding imag-binding) (binding-names)
|
#:with (real-binding imag-binding) (binding-names)
|
||||||
#:do [(log-unboxing-opt "make-rectangular elimination")]
|
#:do [(log-unboxing-opt "make-rectangular elimination")]
|
||||||
#:with (bindings ...)
|
#:with (bindings ...)
|
||||||
#'(((real-binding) real.opt)
|
#'(((real-binding) real.opt)
|
||||||
((imag-binding) imag.opt)))
|
((imag-binding) imag.opt)))
|
||||||
(pattern (#%plain-app op:make-polar^ r:float-arg-expr theta:float-arg-expr)
|
(pattern (#%plain-app op:make-polar^ r:float-arg-expr theta:float-arg-expr)
|
||||||
#:when (subtypeof? this-syntax -FloatComplex)
|
#:when (or (subtypeof? this-syntax -FloatComplex)
|
||||||
|
(and (log-missed-complex-expr) #f))
|
||||||
#:with radius (generate-temporary)
|
#:with radius (generate-temporary)
|
||||||
#:with angle (generate-temporary)
|
#:with angle (generate-temporary)
|
||||||
#:with (real-binding imag-binding) (binding-names)
|
#:with (real-binding imag-binding) (binding-names)
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
#;#;
|
#;#;
|
||||||
#<<END
|
#<<END
|
||||||
TR opt: complex-exp.rkt 15:0 (- (exp 0) 1.0+2.0i) -- unboxed binary float complex
|
TR missed opt: complex-exp.rkt 16:3 (exp 0) -- Non complex value in complex arithmetic
|
||||||
TR opt: complex-exp.rkt 15:11 1.0+2.0i -- unboxed literal
|
TR opt: complex-exp.rkt 16:0 (- (exp 0) 1.0+2.0i) -- unboxed binary float complex
|
||||||
TR opt: complex-exp.rkt 15:3 (exp 0) -- float-arg-expr in complex ops
|
TR opt: complex-exp.rkt 16:11 1.0+2.0i -- unboxed literal
|
||||||
TR opt: complex-exp.rkt 15:8 0 -- float-arg-expr in complex ops
|
TR opt: complex-exp.rkt 16:3 (exp 0) -- float-arg-expr in complex ops
|
||||||
|
TR opt: complex-exp.rkt 16:8 0 -- float-arg-expr in complex ops
|
||||||
END
|
END
|
||||||
#<<END
|
#<<END
|
||||||
0.0-2.0i
|
0.0-2.0i
|
||||||
|
|
Loading…
Reference in New Issue
Block a user