Fix unsound fxquotient optimization.
Closes PR13827. original commit: 5e304161100ee53c1150476b837e21a1baa820f3
This commit is contained in:
parent
f8cbf0dccd
commit
a598ba1617
|
@ -25,7 +25,7 @@ TR opt: fixnum-bounded-expr.rkt 99:5 (+ 300 301) -- fixnum bounded expr
|
|||
TR opt: fixnum-bounded-expr.rkt 99:17 (+ 301 302) -- fixnum bounded expr
|
||||
TR opt: fixnum-bounded-expr.rkt 99:0 (fx- (+ 300 301) (+ 301 302)) -- fixnum fx-
|
||||
TR opt: fixnum-bounded-expr.rkt 102:0 (fx* 4 5) -- fixnum fx*
|
||||
TR opt: fixnum-bounded-expr.rkt 105:0 (fxquotient (ann 34 Nonnegative-Fixnum) (ann -4 Fixnum)) -- fixnum fxquotient
|
||||
TR opt: fixnum-bounded-expr.rkt 105:0 (fxquotient (ann 34 Nonnegative-Fixnum) (ann -4 Negative-Fixnum)) -- fixnum fxquotient
|
||||
TR opt: fixnum-bounded-expr.rkt 108:0 (fxabs (ann 64235 Nonnegative-Fixnum)) -- fixnum fxabs
|
||||
28
|
||||
89525
|
||||
|
@ -102,7 +102,7 @@ TR opt: fixnum-bounded-expr.rkt 108:0 (fxabs (ann 64235 Nonnegative-Fixnum)) --
|
|||
(fx* 4 5) ; ok, (* Byte Byte)
|
||||
(fx* 300 300) ; not ok
|
||||
|
||||
(fxquotient (ann 34 Nonnegative-Fixnum) (ann -4 Fixnum))
|
||||
(fxquotient (ann 34 Nonnegative-Fixnum) (ann -4 Negative-Fixnum))
|
||||
(fxquotient -4 -5) ; not ok
|
||||
|
||||
(fxabs (ann 64235 Nonnegative-Fixnum)) ; ok
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
#;
|
||||
(
|
||||
TR missed opt: invalid-fxquotient.rkt 10:21 (quotient fixnum-min -1) -- out of fixnum range
|
||||
TR missed opt: invalid-fxquotient.rkt 12:21 (quotient fixnum-min -1) -- out of fixnum range
|
||||
#t
|
||||
)
|
||||
|
||||
#lang typed/racket/base
|
||||
|
||||
(require racket/fixnum)
|
||||
|
||||
(define: fixnum-min : Nonpositive-Fixnum (assert (- (expt 2 30)) fixnum?))
|
||||
(define: q : Natural (quotient fixnum-min -1)) ; this can't be optimized safely
|
||||
(= 1073741824 q)
|
||||
(define (bad) (fxquotient 3 0)) ; can't be optimized
|
||||
|
|
|
@ -194,9 +194,8 @@
|
|||
(begin (log-optimization "fixnum fx*" fixnum-opt-msg this-syntax)
|
||||
(add-disappeared-use #'op)
|
||||
#'(unsafe-fx* n1.opt n2.opt)))
|
||||
(pattern (#%plain-app (~and op (~literal fxquotient)) n1:fixnum-expr n2:fixnum-expr)
|
||||
#:when (and (subtypeof? #'n1 -NonNegFixnum)
|
||||
(subtypeof? #'n2 -Fixnum))
|
||||
(pattern (#%plain-app (~and op (~literal fxquotient)) n1:fixnum-expr n2:nonzero-fixnum-expr)
|
||||
#:when (subtypeof? #'n1 -NonNegFixnum)
|
||||
#:with opt
|
||||
(begin (log-optimization "fixnum fxquotient" fixnum-opt-msg this-syntax)
|
||||
(add-disappeared-use #'op)
|
||||
|
|
Loading…
Reference in New Issue
Block a user