Fix unsound unary fixnum subtraction optimization.

Closes PR13826.

original commit: 93d4a5d4266511166de9e8549afec89922a4eb84
This commit is contained in:
Vincent St-Amour 2013-06-06 13:01:43 -04:00
parent a8abe6ce83
commit f8cbf0dccd
2 changed files with 8 additions and 1 deletions

View File

@ -1,10 +1,15 @@
#;
(
TR opt: unary-fixnum.rkt 10:0 (bitwise-not 4) -- unary fixnum
TR opt: unary-fixnum.rkt 13:0 (bitwise-not 4) -- unary fixnum
TR opt: unary-fixnum.rkt 14:0 (- (ann 2 Nonnegative-Fixnum)) -- unary fixnum
-5
-2
2
)
#lang typed/scheme
#:optimize
(bitwise-not 4)
(- (ann 2 Nonnegative-Fixnum))
(- (ann -2 Negative-Fixnum)) ; can't optimize negatives

View File

@ -131,6 +131,8 @@
#'(op.unsafe n1.opt n2.opt)))
(pattern (#%plain-app (~and op (~literal -)) f:fixnum-expr)
;; Invalid for `(- <most-negative-fixnum>)'.
#:when (subtypeof? #'f -NonNegFixnum)
#:with opt
(begin (log-optimization "unary fixnum" fixnum-opt-msg this-syntax)
(add-disappeared-use #'op)