From 8ffb3128e4b3ec1da728447a3040fc28ecba784e Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Wed, 7 Jul 2010 22:07:48 -0400 Subject: [PATCH] Fixed pessimization of some complex code. original commit: ea8523bd63665f5330d25c7babf3872298f1e570 --- collects/typed-scheme/private/optimize.rkt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/collects/typed-scheme/private/optimize.rkt b/collects/typed-scheme/private/optimize.rkt index a58227ca..e21a8018 100644 --- a/collects/typed-scheme/private/optimize.rkt +++ b/collects/typed-scheme/private/optimize.rkt @@ -70,11 +70,11 @@ (format-unique-id #'here "unboxed-gensym-~a" *unboxed-gensym-counter*)) (define-syntax-class inexact-complex-opt-expr - (pattern e:unboxed-inexact-complex-opt-expr - #:with opt - (begin (set! *unboxed-gensym-counter* 0) - #'(let* (e.bindings ...) - (unsafe-make-flrectangular e.real-part e.imag-part))))) + (pattern e:opt-expr + #:when (match (type-of #'e) + [(tc-result1: (== -InexactComplex type-equal?)) #t] [_ #f]) + + #:with opt #'e.opt)) ;; it's faster to take apart a complex number and use unsafe operations on ;; its parts than it is to use generic operations ;; we keep the real and imaginary parts unboxed as long as we stay within @@ -327,10 +327,12 @@ (begin (log-optimization "unary inexact complex" #'op) #'(op.unsafe n.opt))) (pattern (~and exp (#%plain-app (~var op (float-op binary-inexact-complex-ops)) e:inexact-complex-opt-expr ...)) - #:with exp*:inexact-complex-opt-expr #'exp + #:with exp*:unboxed-inexact-complex-opt-expr #'exp #:with opt (begin (log-optimization "unboxed inexact complex" #'exp) - #'exp*.opt)) + (begin (set! *unboxed-gensym-counter* 0) + #'(let* (exp*.bindings ...) + (unsafe-make-flrectangular exp*.real-part exp*.imag-part))))) (pattern (#%plain-app (~and op (~literal exact->inexact)) n:fixnum-opt-expr) #:with opt