From db9d51fef7505776a7250446496c1784043472e1 Mon Sep 17 00:00:00 2001 From: Vincent St-Amour Date: Thu, 14 Jul 2011 18:35:35 -0400 Subject: [PATCH] Change the structure of the "extra precision" missed optimizations. Avoids reports that are almost duplicates. --- .../missed-optimizations/nested-same-kind.rkt | 17 +++++----- collects/typed-scheme/optimizer/float.rkt | 34 +++++++++++-------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/collects/tests/typed-scheme/optimizer/missed-optimizations/nested-same-kind.rkt b/collects/tests/typed-scheme/optimizer/missed-optimizations/nested-same-kind.rkt index 6b7a01c5ea..1ef7320b3c 100644 --- a/collects/tests/typed-scheme/optimizer/missed-optimizations/nested-same-kind.rkt +++ b/collects/tests/typed-scheme/optimizer/missed-optimizations/nested-same-kind.rkt @@ -1,14 +1,13 @@ #; ( -TR missed opt: nested-same-kind.rkt 25:0 (* 2.0 (* 3.0 (ann 4 Integer))) -- exact ops inside float expr -- caused by: 25:7 (* 3.0 (ann 4 Integer)) -TR missed opt: nested-same-kind.rkt 25:0 (* 2.0 (* 3.0 (ann 4 Integer))) -- all args float-arg-expr, result not Float -- caused by: 25:19 4 (2 times) -TR missed opt: nested-same-kind.rkt 26:0 (* 1.0 (* 2.0 (* 3.0 (ann 4 Integer)))) -- exact ops inside float expr -- caused by: 26:14 (* 3.0 (ann 4 Integer)) (2 times) -TR missed opt: nested-same-kind.rkt 26:0 (* 1.0 (* 2.0 (* 3.0 (ann 4 Integer)))) -- all args float-arg-expr, result not Float -- caused by: 26:26 4 (3 times) -TR missed opt: nested-same-kind.rkt 27:0 (* 2.0 (* 3.0 (ann 4 Integer) (ann 5 Integer))) -- exact ops inside float expr -- caused by: 27:7 (* 3.0 (ann 4 Integer) (ann 5 Integer)) -TR missed opt: nested-same-kind.rkt 27:0 (* 2.0 (* 3.0 (ann 4 Integer) (ann 5 Integer))) -- all args float-arg-expr, result not Float -- caused by: 27:19 4, 27:35 5 (2 times) -TR missed opt: nested-same-kind.rkt 28:0 (* (* 3.0 (ann 4 Integer)) (* 3.0 (ann 4 Integer))) -- exact ops inside float expr -- caused by: 28:27 (* 3.0 (ann 4 Integer)) -TR missed opt: nested-same-kind.rkt 28:0 (* (* 3.0 (ann 4 Integer)) (* 3.0 (ann 4 Integer))) -- exact ops inside float expr -- caused by: 28:3 (* 3.0 (ann 4 Integer)) -TR missed opt: nested-same-kind.rkt 28:0 (* (* 3.0 (ann 4 Integer)) (* 3.0 (ann 4 Integer))) -- all args float-arg-expr, result not Float -- caused by: 28:15 4, 28:39 4 (3 times) +TR missed opt: nested-same-kind.rkt 24:0 (* 2.0 (* 3.0 (ann 4 Integer))) -- exact ops inside float expr -- caused by: 24:7 (* 3.0 (ann 4 Integer)) +TR missed opt: nested-same-kind.rkt 24:0 (* 2.0 (* 3.0 (ann 4 Integer))) -- all args float-arg-expr, result not Float -- caused by: 24:19 4 (2 times) +TR missed opt: nested-same-kind.rkt 25:0 (* 1.0 (* 2.0 (* 3.0 (ann 4 Integer)))) -- exact ops inside float expr -- caused by: 25:14 (* 3.0 (ann 4 Integer)) (2 times) +TR missed opt: nested-same-kind.rkt 25:0 (* 1.0 (* 2.0 (* 3.0 (ann 4 Integer)))) -- all args float-arg-expr, result not Float -- caused by: 25:26 4 (3 times) +TR missed opt: nested-same-kind.rkt 26:0 (* 2.0 (* 3.0 (ann 4 Integer) (ann 5 Integer))) -- exact ops inside float expr -- caused by: 26:7 (* 3.0 (ann 4 Integer) (ann 5 Integer)) +TR missed opt: nested-same-kind.rkt 26:0 (* 2.0 (* 3.0 (ann 4 Integer) (ann 5 Integer))) -- all args float-arg-expr, result not Float -- caused by: 26:19 4, 26:35 5 (2 times) +TR missed opt: nested-same-kind.rkt 27:0 (* (* 3.0 (ann 4 Integer)) (* 3.0 (ann 4 Integer))) -- exact ops inside float expr -- caused by: 27:3 (* 3.0 (ann 4 Integer)), 27:27 (* 3.0 (ann 4 Integer)) +TR missed opt: nested-same-kind.rkt 27:0 (* (* 3.0 (ann 4 Integer)) (* 3.0 (ann 4 Integer))) -- all args float-arg-expr, result not Float -- caused by: 27:15 4, 27:39 4 (3 times) 24.0 24.0 120.0 diff --git a/collects/typed-scheme/optimizer/float.rkt b/collects/typed-scheme/optimizer/float.rkt index 9e5d4b94dc..8e0a52fc0b 100644 --- a/collects/typed-scheme/optimizer/float.rkt +++ b/collects/typed-scheme/optimizer/float.rkt @@ -121,21 +121,25 @@ ;; use cases for computing exact intermediate results, then converting them to ;; floats at the end. (when (or safe-to-opt? missed-optimization?) - (for ([subexpr (in-list (syntax->list #'(f1 f2 fs ...)))] - #:when (or (in-real-layer? subexpr) - (in-rational-layer? subexpr))) - (syntax-parse subexpr - ;; Only warn about subexpressions that actually perform exact arithmetic. - ;; There's not much point in warning about literals/variables that will - ;; be coerced anyway, or about things like: - ;; (vector-ref vector-of-rationals x) - ;; which don't perform arithmetic despite returning numbers. - [e:arith-expr - (log-missed-optimization - "exact ops inside float expr" - "This expression has a Float type, but the highlighted subexpression(s) use exact arithmetic. The extra precision of the exact arithmetic will be lost. Using Float types in these subexpression(s) may result in performance gains without significant precision loss." - this-syntax subexpr)] - [_ #f]))) + (define extra-precision-subexprs + (filter + values + (for/list ([subexpr (in-list (syntax->list #'(f1 f2 fs ...)))] + #:when (or (in-real-layer? subexpr) + (in-rational-layer? subexpr))) + (syntax-parse subexpr + ;; Only warn about subexpressions that actually perform exact arithmetic. + ;; There's not much point in warning about literals/variables that will + ;; be coerced anyway, or about things like: + ;; (vector-ref vector-of-rationals x) + ;; which don't perform arithmetic despite returning numbers. + [e:arith-expr #'e] + [_ #f])))) + (when (not (null? extra-precision-subexprs)) + (log-missed-optimization + "exact ops inside float expr" + "This expression has a Float type, but the highlighted subexpression(s) use exact arithmetic. The extra precision of the exact arithmetic will be lost. Using Float types in these subexpression(s) may result in performance gains without significant precision loss." + this-syntax extra-precision-subexprs))) safe-to-opt?) #:with opt (begin (log-optimization "binary float" float-opt-msg this-syntax)