]> gitweb.factorcode.org Git - factor.git/commit
compiler.tree.propagation.transforms: fix redundant-bitand?.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 17 Mar 2021 03:52:37 +0000 (20:52 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 17 Mar 2021 04:17:00 +0000 (21:17 -0700)
commitb2ad97aa9707328ac8a9ada70611a7c9c4aad193
treedb539d42bc603014f2553cc00bd3ea7d0049eb30
parent02ec165bcde35b5ffe65d1c7d71dd6518a97ccee
compiler.tree.propagation.transforms: fix redundant-bitand?.

When removing a redundant bitand (for example, in ``W*`` which does ``64
on-bits bitand``) make sure that we leave the ``>bignum`` to convert the
input integer to a bignum since the output type propagation assumes that
to be the case and we compiled the following code wrong.

    : mult ( a b -- x ) [ 32 bits ] bi@ W* ;

Before:

    \ mult optimized.
    [
        >R 4294967295 >R integer>fixnum R> fixnum-bitand
        R> 4294967295 >R integer>fixnum R> fixnum-bitand fixnum*
    ]

After:

    \ mult optimized.
    [
        >R 4294967295 >R integer>fixnum R> fixnum-bitand
        R> 4294967295 >R integer>fixnum R> fixnum-bitand fixnum*
        >bignum
    ]
basis/compiler/tree/propagation/transforms/transforms.factor