Optimize coercion of integer literals.
original commit: bdf84f371d4ccf952e08251703a4249c37f81a85
This commit is contained in:
parent
4c41407d64
commit
82340857d9
|
@ -1,4 +1,4 @@
|
|||
(module float-promotion typed/scheme #:optimize
|
||||
(require racket/unsafe/ops racket/flonum)
|
||||
(+ 1 2.0)
|
||||
(+ (quotient 1 1) 2.0)
|
||||
(+ (expt 100 100) 2.0))
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#lang typed/scheme #:optimize
|
||||
(require racket/unsafe/ops)
|
||||
(+ 2 1.0+2.0i 3.0+6.0i)
|
||||
(+ (quotient 2 1) 1.0+2.0i 3.0+6.0i)
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
#lang typed/scheme #:optimize
|
||||
|
||||
(require racket/unsafe/ops)
|
||||
|
||||
(+ 1 2.0)
|
||||
1
|
|
@ -1,7 +1,7 @@
|
|||
#lang scheme/base
|
||||
|
||||
(require syntax/parse
|
||||
syntax/id-table racket/dict
|
||||
syntax/id-table racket/dict scheme/flonum
|
||||
(for-template scheme/base scheme/flonum scheme/unsafe/ops)
|
||||
"../utils/utils.rkt"
|
||||
(types abbrev type-table utils subtype)
|
||||
|
@ -59,6 +59,11 @@
|
|||
;; note: none of the unary operations have types where non-float arguments
|
||||
;; can result in float (as opposed to real) results
|
||||
(define-syntax-class float-arg-expr
|
||||
;; we can convert literals right away
|
||||
(pattern (quote n)
|
||||
#:when (exact-integer? (syntax->datum #'n))
|
||||
#:with opt
|
||||
(datum->syntax #'here (->fl (syntax->datum #'n))))
|
||||
(pattern e:fixnum-expr
|
||||
#:with opt #'(unsafe-fx->fl e.opt))
|
||||
(pattern e:int-expr
|
||||
|
|
Loading…
Reference in New Issue
Block a user