Refactor arithmetic hidden cost logging.
This commit is contained in:
parent
e82a0ee608
commit
50777aaca4
|
@ -261,33 +261,33 @@
|
||||||
#'(unsafe-fl- n.opt 1.0)))
|
#'(unsafe-fl- n.opt 1.0)))
|
||||||
|
|
||||||
;; warn about (potentially) exact real arithmetic, in general
|
;; warn about (potentially) exact real arithmetic, in general
|
||||||
|
;; Note: These patterns don't perform optimization. They only produce logging
|
||||||
|
;; for consumption by Optimization Coach.
|
||||||
(pattern (#%plain-app (~var op (float-op binary-float-ops))
|
(pattern (#%plain-app (~var op (float-op binary-float-ops))
|
||||||
n ...)
|
n ...)
|
||||||
#:when (and (subtypeof? this-syntax -Real)
|
#:when (maybe-exact-rational? this-syntax)
|
||||||
(not (subtypeof? this-syntax -Flonum))
|
|
||||||
(not (subtypeof? this-syntax -Int)))
|
|
||||||
#:with opt
|
#:with opt
|
||||||
(begin (log-optimization-info "exact real arith"
|
(begin (log-optimization-info "exact real arith"
|
||||||
this-syntax)
|
this-syntax)
|
||||||
this-syntax)) ; no change
|
this-syntax))
|
||||||
(pattern (#%plain-app (~var op (float-op binary-float-comps))
|
(pattern (#%plain-app (~var op (float-op binary-float-comps))
|
||||||
n ...)
|
n ...)
|
||||||
;; can't look at return type, since it's always bool
|
;; can't look at return type, since it's always bool
|
||||||
#:when (for/and ([arg (syntax->list #'(n ...))])
|
#:when (andmap maybe-exact-rational? (syntax->list #'(n ...)))
|
||||||
(and (subtypeof? arg -Real)
|
|
||||||
(not (subtypeof? arg -Flonum))
|
|
||||||
(not (subtypeof? arg -Int))))
|
|
||||||
#:with opt
|
#:with opt
|
||||||
(begin (log-optimization-info "exact real arith"
|
(begin (log-optimization-info "exact real arith"
|
||||||
this-syntax)
|
this-syntax)
|
||||||
this-syntax)) ; no change
|
this-syntax))
|
||||||
(pattern (#%plain-app (~var op (float-op unary-float-ops))
|
(pattern (#%plain-app (~var op (float-op unary-float-ops))
|
||||||
n ...)
|
n ...)
|
||||||
#:when (and (subtypeof? this-syntax -Real)
|
#:when (maybe-exact-rational? this-syntax)
|
||||||
(not (subtypeof? this-syntax -Flonum))
|
|
||||||
(not (subtypeof? this-syntax -Int)))
|
|
||||||
#:with opt
|
#:with opt
|
||||||
(begin (log-optimization-info "exact real arith"
|
(begin (log-optimization-info "exact real arith"
|
||||||
this-syntax)
|
this-syntax)
|
||||||
this-syntax)) ; no change
|
this-syntax))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
(define (maybe-exact-rational? stx)
|
||||||
|
(and (subtypeof? stx -Real)
|
||||||
|
(not (subtypeof? stx -Flonum))
|
||||||
|
(not (subtypeof? stx -Int))))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user