cinder icon indicating copy to clipboard operation
cinder copied to clipboard

No pattern found for opcode Fadd: Xxr

Open belm0 opened this issue 3 years ago • 2 comments

$ docker run -v $PWD:/vol -it --rm ghcr.io/facebookincubator/cinder-runtime:cinder-3.8 -X jit -m compiler --static vol/autogen_bug.py
JIT: /cinder/src/Jit/codegen/autogen.cpp:143 -- assertion failed: func != nullptr
No pattern found for opcode Fadd: Xxr
from __static__ import box, double, inline

@inline
def foo(a: double, b: double) -> double:
    return b - a

def main():
    c: double = 0.
    for _ in range(10):
        c += foo(.4, .97)
    print('done', box(c))

if __name__ == '__main__':
    main()

The problem goes away if @inline is removed.

See in seen in cinder-3.8.6c2de94

belm0 avatar Jul 04 '22 06:07 belm0

workaround is to explicitly cast the float literals to double:

c += foo(double(.4), double(.97))

it's surprising to have @inline change the conventions of implicit conversion of the args

belm0 avatar Jul 04 '22 07:07 belm0

Yes, inlining definitely shouldn't have that effect, this is just a bug where the JIT is missing support for some float operations, it looks like. Float support is unfortunately not super well baked still (we don't use it much in prod), but we should be able to to get around to fixing this at some point, thanks for the report!

carljm avatar Jul 12 '22 03:07 carljm