compiler.tree.modular-arithmetic: >fixnum elimination and value info annotations were too aggressive
parent
aeb33f5f15
commit
a742145fd9
|
@ -249,3 +249,12 @@ cell {
|
||||||
{ fixnum+ >fixnum } inlined?
|
{ fixnum+ >fixnum } inlined?
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
[ f ] [
|
||||||
|
[ f >fixnum ]
|
||||||
|
{ >fixnum } inlined?
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ f ] [
|
||||||
|
[ [ >fixnum ] 2dip set-alien-unsigned-1 ]
|
||||||
|
{ >fixnum } inlined?
|
||||||
|
] unit-test
|
|
@ -124,22 +124,12 @@ SYMBOL: changed?
|
||||||
GENERIC: optimize-modular-arithmetic* ( node -- nodes )
|
GENERIC: optimize-modular-arithmetic* ( node -- nodes )
|
||||||
|
|
||||||
M: #push optimize-modular-arithmetic*
|
M: #push optimize-modular-arithmetic*
|
||||||
dup out-d>> first modular-value? [
|
dup [ out-d>> first modular-value? ] [ literal>> real? ] bi and
|
||||||
[ >fixnum ] change-literal
|
[ [ >fixnum ] change-literal ] when ;
|
||||||
] when ;
|
|
||||||
|
|
||||||
: input-will-be-fixnum? ( #call -- ? )
|
|
||||||
in-d>> first actually-defined-by
|
|
||||||
[ value>> { [ modular-value? ] [ fixnum-value? ] } 1&& ] all? ;
|
|
||||||
|
|
||||||
: output-will-be-coerced? ( #call -- ? )
|
|
||||||
out-d>> first modular-value? ;
|
|
||||||
|
|
||||||
: redundant->fixnum? ( #call -- ? )
|
: redundant->fixnum? ( #call -- ? )
|
||||||
{
|
in-d>> first actually-defined-by
|
||||||
[ input-will-be-fixnum? ]
|
[ value>> { [ modular-value? ] [ fixnum-value? ] } 1&& ] all? ;
|
||||||
[ output-will-be-coerced? ]
|
|
||||||
} 1|| ;
|
|
||||||
|
|
||||||
: optimize->fixnum ( #call -- nodes )
|
: optimize->fixnum ( #call -- nodes )
|
||||||
dup redundant->fixnum? [ drop f ] when ;
|
dup redundant->fixnum? [ drop f ] when ;
|
||||||
|
@ -172,7 +162,7 @@ MEMO: fixnum-coercion ( flags -- nodes )
|
||||||
] when ;
|
] when ;
|
||||||
|
|
||||||
: optimize-low-order-op ( #call -- nodes )
|
: optimize-low-order-op ( #call -- nodes )
|
||||||
dup in-d>> first modular-value? [
|
dup in-d>> first fixnum-value? [
|
||||||
[ ] [ in-d>> first ] [ info>> ] tri
|
[ ] [ in-d>> first ] [ info>> ] tri
|
||||||
[ drop fixnum <class-info> ] change-at
|
[ drop fixnum <class-info> ] change-at
|
||||||
] when ;
|
] when ;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
USING: tools.test byte-arrays sequences kernel ;
|
USING: tools.test byte-arrays sequences kernel math ;
|
||||||
IN: byte-arrays.tests
|
IN: byte-arrays.tests
|
||||||
|
|
||||||
[ 6 B{ 1 2 3 } ] [
|
[ 6 B{ 1 2 3 } ] [
|
||||||
|
@ -11,3 +11,7 @@ IN: byte-arrays.tests
|
||||||
[ -10 B{ } resize-byte-array ] must-fail
|
[ -10 B{ } resize-byte-array ] must-fail
|
||||||
|
|
||||||
[ B{ 123 } ] [ 123 1byte-array ] unit-test
|
[ B{ 123 } ] [ 123 1byte-array ] unit-test
|
||||||
|
|
||||||
|
[ B{ 123 } ] [ 123 0 B{ 0 } [ set-nth ] keep ] unit-test
|
||||||
|
|
||||||
|
[ B{ 123 } ] [ 123 >bignum 0 B{ 0 } [ set-nth ] keep ] unit-test
|
|
@ -1,5 +1,5 @@
|
||||||
USING: tools.test io.streams.byte-array io.encodings.binary
|
USING: tools.test io.streams.byte-array io.encodings.binary
|
||||||
io.encodings.utf8 io kernel arrays strings namespaces ;
|
io.encodings.utf8 io kernel arrays strings namespaces math ;
|
||||||
|
|
||||||
[ B{ } ] [ B{ } binary [ contents ] with-byte-reader ] unit-test
|
[ B{ } ] [ B{ } binary [ contents ] with-byte-reader ] unit-test
|
||||||
[ B{ 1 2 3 } ] [ binary [ B{ 1 2 3 } write ] with-byte-writer ] unit-test
|
[ B{ 1 2 3 } ] [ binary [ B{ 1 2 3 } write ] with-byte-writer ] unit-test
|
||||||
|
@ -28,3 +28,8 @@ io.encodings.utf8 io kernel arrays strings namespaces ;
|
||||||
read1
|
read1
|
||||||
] with-byte-reader
|
] with-byte-reader
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
! Overly aggressive compiler optimizations
|
||||||
|
[ B{ 123 } ] [
|
||||||
|
binary [ 123 >bignum write1 ] with-byte-writer
|
||||||
|
] unit-test
|
Loading…
Reference in New Issue