diff --git a/collects/tests/typed-scheme/optimizer/close-calls/real-in-float-expr.rkt b/collects/tests/typed-scheme/optimizer/close-calls/real-in-float-expr.rkt index 0d826c18..f68872af 100644 --- a/collects/tests/typed-scheme/optimizer/close-calls/real-in-float-expr.rkt +++ b/collects/tests/typed-scheme/optimizer/close-calls/real-in-float-expr.rkt @@ -1,9 +1,11 @@ #; ( - real-in-float-expr.rkt 10:0 (#%app * (quote 3) (quote 2.3)) -- binary, args all float-arg-expr, return type not Float + real-in-float-expr.rkt 12:0 (#%app * (quote 3) (quote 2.3)) -- binary, args all float-arg-expr, return type not Float -- caused by: 10:8 (quote 3) + real-in-float-expr.rkt 18:0 (#%app * (quote 2) (quote 2.0)) -- binary, args all float-arg-expr, return type not Float -- caused by: 17:8 (quote 2) 6.8999999999999995 6 5 + 4.0 ) #lang typed/racket @@ -12,3 +14,5 @@ (* (ann 2 Integer) (ann 3 Integer)) ; but these have nothing to do with floats, should not be logged (+ (ann 2 Integer) (ann 3 Integer)) + +(* (ann 2 Natural) 2.0) ; close calls that result in Nonnegative-Real and co (i.e. not directly Real) should be reported too diff --git a/collects/typed-scheme/optimizer/float.rkt b/collects/typed-scheme/optimizer/float.rkt index e49375f5..bb11913a 100644 --- a/collects/typed-scheme/optimizer/float.rkt +++ b/collects/typed-scheme/optimizer/float.rkt @@ -89,12 +89,15 @@ #:when (let ([safe-to-opt? (subtypeof? this-syntax -Flonum)]) ;; if we don't have a return type of float, we missed an optimization ;; opportunity, report it + ;; ignore operations that stay within integers or rationals, since + ;; these have nothing to do with float optimizations (when (and (not safe-to-opt?) - (isoftype? this-syntax -Real)) + (in-real-layer? this-syntax)) (log-close-call "binary, args all float-arg-expr, return type not Float" this-syntax - (for/first ([x (in-list (syntax->list #'(f1 f2 fs ...)))]) - (not (subtypeof? x -Flonum))))) + (for/first ([x (in-list (syntax->list #'(f1 f2 fs ...)))] + #:when (not (subtypeof? x -Flonum))) + x))) safe-to-opt?) #:with opt (begin (log-optimization "binary float" #'op)