From 6245807b7c2715936d30e48c908920196e158f65 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Tue, 13 Oct 2015 14:57:20 -0500 Subject: [PATCH] Log uses of float vectors. For OC to recommend using flvectors instead. --- .../typed-racket/optimizer/hidden-costs.rkt | 12 ++++++++++-- .../optimizer/missed-optimizations/float-vector.rkt | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 typed-racket-test/optimizer/missed-optimizations/float-vector.rkt diff --git a/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt b/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt index 1fc6f100..ed5b3311 100644 --- a/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt +++ b/typed-racket-lib/typed-racket/optimizer/hidden-costs.rkt @@ -4,7 +4,7 @@ (for-template racket/base) "../utils/utils.rkt" (optimizer utils logging) - (types abbrev struct-table)) + (types abbrev numeric-tower struct-table)) (provide hidden-cost-log-expr) @@ -64,4 +64,12 @@ #:when (not (or (subtypeof? #'pattern-arg -Regexp) (subtypeof? #'pattern-arg -Byte-Regexp))) #:do [(log-optimization-info "non-regexp pattern" #'pattern-arg)] - #:with opt (syntax/loc this-syntax (op pattern-arg.opt args.opt ...)))) + #:with opt (syntax/loc this-syntax (op pattern-arg.opt args.opt ...))) + + ;; vectors of floats can be replaced with flvectors in most cases + ;; need to deconstruct to not infinite loop + (pattern (#%plain-app es ...) + #:when (subtypeof? this-syntax (-vec -Flonum)) + #:with (es*:opt-expr ...) #'(es ...) + #:do [(log-optimization-info "vector of floats" this-syntax)] + #:with opt (syntax/loc this-syntax (es*.opt ...)))) diff --git a/typed-racket-test/optimizer/missed-optimizations/float-vector.rkt b/typed-racket-test/optimizer/missed-optimizations/float-vector.rkt new file mode 100644 index 00000000..3a7087c0 --- /dev/null +++ b/typed-racket-test/optimizer/missed-optimizations/float-vector.rkt @@ -0,0 +1,3 @@ +#lang typed/racket + +(vector 3.2 3.4)