From 758a055b0bb428179bdccb256d7119d594458af9 Mon Sep 17 00:00:00 2001 From: Eric Dobson Date: Sat, 22 Feb 2014 14:55:24 -0800 Subject: [PATCH] Change float optimizations to not warn on projections. original commit: b89a56e0ec4e561ae70b823be3140b860be3d34c --- .../typed-racket/optimizer/float.rkt | 15 +++++++++++---- .../tests/typed-racket/optimizer/tests/expt.rkt | 1 - .../tests/invalid-inexact-complex-parts.rkt | 1 - .../optimizer/tests/invalid-log-complex.rkt | 1 - 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/float.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/float.rkt index 6eff36f0..577e72e6 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/float.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/optimizer/float.rkt @@ -23,11 +23,17 @@ ;; unlike binary-float-ops #'make-rectangular #'unsafe-make-flrectangular #'make-flrectangular #'unsafe-make-flrectangular)) -(define unary-float-ops - (dict-set* + +(define unary-float-math-ops + (dict-set (mk-float-tbl (list #'abs #'sin #'cos #'tan #'asin #'acos #'atan #'log #'exp #'sqrt #'round #'floor #'ceiling #'truncate)) - #'magnitude #'unsafe-flabs + #'magnitude #'unsafe-flabs)) + + +(define unary-float-ops + (dict-set* + unary-float-math-ops #'real-part #'#%expression #'flreal-part #'#%expression #'unsafe-flreal-part #'#%experession)) @@ -57,6 +63,7 @@ (define-syntax-class/specialize int-expr (subtyped-expr -Integer)) (define-syntax-class/specialize real-expr (subtyped-expr -Real)) (define-syntax-class/specialize unary-float-op (float-op unary-float-ops)) +(define-syntax-class/specialize unary-float-math-op (float-op unary-float-math-ops)) (define-syntax-class/specialize binary-float-op (float-op binary-float-ops)) (define-syntax-class/specialize binary-float-comp (float-op binary-float-comps)) @@ -284,7 +291,7 @@ #:when (andmap maybe-exact-rational? (syntax->list #'(n ...))) #:do [(log-opt-info "possible exact real arith")] #:with opt #'(op n.opt ...)) - (pattern (#%plain-app op:unary-float-op n:opt-expr ...) + (pattern (#%plain-app op:unary-float-math-op n:opt-expr ...) #:when (maybe-exact-rational? this-syntax) #:do [(log-opt-info "possible exact real arith")] #:with opt #'(op n.opt ...)) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/expt.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/expt.rkt index 63bac1ba..1f16401e 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/expt.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/optimizer/tests/expt.rkt @@ -1,6 +1,5 @@ #;#; #<