Fix bug in optimizer with unboxed let constants.

original commit: 676be5de066b561d33f0b4cb40fe6537eda59d02
This commit is contained in:
Eric Dobson 2013-09-19 22:02:26 -07:00
parent 52c5718acc
commit ce1ef7caa7
2 changed files with 24 additions and 9 deletions

View File

@ -112,15 +112,9 @@
#:with (opt-candidates:unboxed-let-clause ...) #'(candidates ...)
#:with (opt-functions:unboxed-fun-clause ...) #'(function-candidates ...)
#:with (opt-others:opt-let-clause ...) #'(others ...)
;; only log when we actually optimize
#:do [(unless (zero? (syntax-length #'(opt-candidates.id ...)))
;; only log when we actually optimize
(log-opt "unboxed let bindings" arity-raising-opt-msg))
;; add the unboxed bindings to the table, for them to be used by
;; further optimizations
(for ((v (in-syntax #'(opt-candidates.id ...)))
(r (in-syntax #'(opt-candidates.real-binding ...)))
(i (in-syntax #'(opt-candidates.imag-binding ...))))
(add-unboxed-var! v r i))]
(log-opt "unboxed let bindings" arity-raising-opt-msg))]
;; in the case where no bindings are unboxed, we create a let
;; that is equivalent to the original, but with all parts optimized
#:with opt (quasisyntax/loc/origin
@ -228,7 +222,8 @@
(define-syntax-class unboxed-let-clause
#:commit
#:attributes (id real-binding imag-binding (bindings 1))
(pattern ((id:id) :unboxed-float-complex-opt-expr)))
(pattern ((id:id) :unboxed-float-complex-opt-expr)
#:do [(add-unboxed-var! #'id #'real-binding #'imag-binding)]))
;; let clause whose rhs is a function with some float complex arguments
;; these arguments may be unboxed

View File

@ -0,0 +1,20 @@
#;#;
#<<END
TR opt: unboxed-let-constants.rkt 18:0 (letrec-values (((x) 5.0+5.0i) ((z) x)) (real-part (+ x z))) -- unboxed let bindings
TR opt: unboxed-let-constants.rkt 18:21 5.0+5.0i -- unboxed literal
TR opt: unboxed-let-constants.rkt 19:21 x -- leave var unboxed
TR opt: unboxed-let-constants.rkt 20:13 (+ x z) -- unboxed binary float complex
TR opt: unboxed-let-constants.rkt 20:16 x -- leave var unboxed
TR opt: unboxed-let-constants.rkt 20:18 z -- leave var unboxed
TR opt: unboxed-let-constants.rkt 20:2 (real-part (+ x z)) -- complex accessor elimination
END
#<<END
10.0
END
#lang typed/racket
(letrec-values (((x) 5.0+5.0i)
((z) x))
(real-part (+ x z)))