Only optimize fixnum comparisons in the binary case.
Closes PR 12479. original commit: e3be06117116bb622a410f44ee5e06f8c3f4f713
This commit is contained in:
parent
f43114c41f
commit
ca115092ff
|
@ -1,6 +1,6 @@
|
|||
#;
|
||||
(
|
||||
TR opt: fixnum-comparison.rkt 12:0 (< (vector-length (quote #(1 2 3))) (string-length "asdf")) -- binary fixnum
|
||||
TR opt: fixnum-comparison.rkt 12:0 (< (vector-length (quote #(1 2 3))) (string-length "asdf")) -- binary fixnum comp
|
||||
TR opt: fixnum-comparison.rkt 12:3 (vector-length (quote #(1 2 3))) -- vector-length
|
||||
TR opt: fixnum-comparison.rkt 12:29 (string-length "asdf") -- string-length
|
||||
#t
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
#;
|
||||
(
|
||||
#t
|
||||
)
|
||||
|
||||
#lang typed/racket/base
|
||||
#:optimize
|
||||
|
||||
;; PR 12479
|
||||
;; was incorrectly optimized in the same way as fixnum bitwise-and and co
|
||||
(= 1 1 1)
|
|
@ -1,9 +1,9 @@
|
|||
#;
|
||||
(
|
||||
TR opt: vector-sum.rkt 41:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- fixnum bounded expr
|
||||
TR opt: vector-sum.rkt 41:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum
|
||||
TR opt: vector-sum.rkt 41:2 (for/fold: ((sum : Float 0.0)) ((i : Nonnegative-Fixnum (in-range l))) (+ sum (vector-ref v i))) -- binary fixnum comp
|
||||
TR opt: vector-sum.rkt 39:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- fixnum bounded expr
|
||||
TR opt: vector-sum.rkt 39:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum
|
||||
TR opt: vector-sum.rkt 39:2 (for: ((i : Nonnegative-Fixnum (in-range l))) (vector-set! v i (sin (exact->inexact i)))) -- binary fixnum comp
|
||||
TR opt: vector-sum.rkt 29:0 #%module-begin -- dead else branch
|
||||
TR opt: vector-sum.rkt 29:0 #%module-begin -- dead else branch
|
||||
TR opt: vector-sum.rkt 29:0 #%module-begin -- dead else branch
|
||||
|
|
|
@ -23,18 +23,22 @@
|
|||
(dict-set
|
||||
(dict-set
|
||||
(dict-set
|
||||
(mk-fixnum-tbl (list #'= #'<= #'< #'> #'>= #'min #'max))
|
||||
(mk-fixnum-tbl (list #'min #'max))
|
||||
#'bitwise-and #'unsafe-fxand)
|
||||
#'fxand #'unsafe-fxand)
|
||||
#'bitwise-ior #'unsafe-fxior)
|
||||
#'fxior #'unsafe-fxior)
|
||||
#'bitwise-xor #'unsafe-fxxor)
|
||||
#'fxxor #'unsafe-fxxor))
|
||||
|
||||
(define binary-fixnum-comps (mk-fixnum-tbl (list #'= #'<= #'< #'> #'>=)))
|
||||
|
||||
(define-syntax-class fixnum-unary-op
|
||||
#:commit
|
||||
(pattern (~or (~literal bitwise-not) (~literal fxnot))
|
||||
#:with unsafe (begin (add-disappeared-use this-syntax)
|
||||
#'unsafe-fxnot)))
|
||||
|
||||
;; closed on fixnums, but 2nd argument must not be 0
|
||||
(define-syntax-class nonzero-fixnum-binary-op
|
||||
#:commit
|
||||
|
@ -106,6 +110,11 @@
|
|||
#:with opt
|
||||
(begin (log-optimization "binary fixnum" fixnum-opt-msg this-syntax)
|
||||
(n-ary->binary #'op.unsafe #'n1.opt #'n2.opt #'(ns.opt ...))))
|
||||
(pattern (#%plain-app (~var op (fixnum-op binary-fixnum-comps))
|
||||
n1:fixnum-expr n2:fixnum-expr)
|
||||
#:with opt
|
||||
(begin (log-optimization "binary fixnum comp" fixnum-opt-msg this-syntax)
|
||||
#'(op.unsafe n1.opt n2.opt)))
|
||||
(pattern (#%plain-app op:nonzero-fixnum-binary-op
|
||||
n1:fixnum-expr
|
||||
n2:nonzero-fixnum-expr)
|
||||
|
|
Loading…
Reference in New Issue
Block a user