From 1105e70b302416c40269c11e60d7ddaa3d14b66e Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Wed, 4 Aug 2010 11:02:33 -0400 Subject: [PATCH] Unbox literals at expansion time. --- .../optimizer/inexact-complex.rkt | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/collects/typed-scheme/optimizer/inexact-complex.rkt b/collects/typed-scheme/optimizer/inexact-complex.rkt index 5fed84154d..d74a9ea632 100644 --- a/collects/typed-scheme/optimizer/inexact-complex.rkt +++ b/collects/typed-scheme/optimizer/inexact-complex.rkt @@ -255,7 +255,32 @@ #:with imag-binding (cadr (syntax->list #'unboxed-info)) #:with (bindings ...) #'()) - ;; else, do the unboxing here + ;; else, do the unboxing here + + ;; we can unbox literals right away + (pattern (quote n) + #:when (let ((x (syntax->datum #'n))) + (and (number? x) + (not (eq? (imag-part x) 0)))) + #:with real-binding (unboxed-gensym) + #:with imag-binding (unboxed-gensym) + #:with (bindings ...) + (let ((n (syntax->datum #'n))) + #`(((real-binding) #,(datum->syntax + #'here + (exact->inexact (real-part n)))) + ((imag-binding) #,(datum->syntax + #'here + (exact->inexact (imag-part n))))))) + (pattern (quote n) + #:when (real? (syntax->datum #'n)) + #:with real-binding (unboxed-gensym) + #:with imag-binding #f + #:with (bindings ...) + #`(((real-binding) #,(datum->syntax + #'here + (exact->inexact (syntax->datum #'n)))))) + (pattern e:expr #:when (isoftype? #'e -InexactComplex) #:with e* (unboxed-gensym)