]> gitweb.factorcode.org Git - factor.git/commit
math.intervals: workaround possible compiler bug by widening interval-bitor.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 31 Oct 2019 17:45:54 +0000 (10:45 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 31 Oct 2019 17:45:54 +0000 (10:45 -0700)
commite256a4ba18fbb7916db2a22ead55cbcbf7cf920d
tree7f8b314f863b9fd5bb6426f756176082cf0ae7eb
parentf68df75b84bf3bf7c3e0f170ede15b4ca34b3161
math.intervals: workaround possible compiler bug by widening interval-bitor.

IN: scratchpad [
                   { byte-array } declare
                   [ 0 alien-unsigned-4 32 shift ]
                   [ 4 alien-unsigned-4 ] bi bitor
                   64 >signed
               ] optimized.

! working
[
    dup >R 0 alien-unsigned-4 32 fixnum-shift
    R> 4 alien-unsigned-4 over tag 0 eq?
    [ fixnum-bitor ] [ fixnum>bignum bignum-bitor ] if
    18446744073709551615 >R >bignum R> bignum-bitand
    dup 63 bignum-bit? [ 18446744073709551616 bignum- ] [ ] if
]

! broken
[
    dup >R 0 alien-unsigned-4 32 fixnum-shift
    R> 4 alien-unsigned-4 over tag 0 eq?
    [ fixnum-bitor ] [ fixnum>bignum bignum-bitor ] if
    dup 63 bignum-bit? [ 18446744073709551616 bignum- ] [ ] if
]

The second case correctly eliminates the bitand but incorrectly assumes
that the item on the stack (which is an integer -- either a fixnum or a
bignum), was converted to a bignum.
basis/math/intervals/intervals-tests.factor
basis/math/intervals/intervals.factor