Fix unsound fxquotient optimization.
Closes PR13827.
This commit is contained in:
parent
93d4a5d426
commit
5e30416110
|
@ -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: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 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 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
|
TR opt: fixnum-bounded-expr.rkt 108:0 (fxabs (ann 64235 Nonnegative-Fixnum)) -- fixnum fxabs
|
||||||
28
|
28
|
||||||
89525
|
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* 4 5) ; ok, (* Byte Byte)
|
||||||
(fx* 300 300) ; not ok
|
(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
|
(fxquotient -4 -5) ; not ok
|
||||||
|
|
||||||
(fxabs (ann 64235 Nonnegative-Fixnum)) ; 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
|
#t
|
||||||
)
|
)
|
||||||
|
|
||||||
#lang typed/racket/base
|
#lang typed/racket/base
|
||||||
|
|
||||||
|
(require racket/fixnum)
|
||||||
|
|
||||||
(define: fixnum-min : Nonpositive-Fixnum (assert (- (expt 2 30)) fixnum?))
|
(define: fixnum-min : Nonpositive-Fixnum (assert (- (expt 2 30)) fixnum?))
|
||||||
(define: q : Natural (quotient fixnum-min -1)) ; this can't be optimized safely
|
(define: q : Natural (quotient fixnum-min -1)) ; this can't be optimized safely
|
||||||
(= 1073741824 q)
|
(= 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)
|
(begin (log-optimization "fixnum fx*" fixnum-opt-msg this-syntax)
|
||||||
(add-disappeared-use #'op)
|
(add-disappeared-use #'op)
|
||||||
#'(unsafe-fx* n1.opt n2.opt)))
|
#'(unsafe-fx* n1.opt n2.opt)))
|
||||||
(pattern (#%plain-app (~and op (~literal fxquotient)) n1:fixnum-expr n2:fixnum-expr)
|
(pattern (#%plain-app (~and op (~literal fxquotient)) n1:fixnum-expr n2:nonzero-fixnum-expr)
|
||||||
#:when (and (subtypeof? #'n1 -NonNegFixnum)
|
#:when (subtypeof? #'n1 -NonNegFixnum)
|
||||||
(subtypeof? #'n2 -Fixnum))
|
|
||||||
#:with opt
|
#:with opt
|
||||||
(begin (log-optimization "fixnum fxquotient" fixnum-opt-msg this-syntax)
|
(begin (log-optimization "fixnum fxquotient" fixnum-opt-msg this-syntax)
|
||||||
(add-disappeared-use #'op)
|
(add-disappeared-use #'op)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user