GithubHelp home page GithubHelp logo

f32/64.neg/abs may be wrong about wasmi HOT 6 CLOSED

wasmi-labs avatar wasmi-labs commented on May 14, 2024 1
f32/64.neg/abs may be wrong

from wasmi.

Comments (6)

pepyakin avatar pepyakin commented on May 14, 2024

It well might be! We didn't spent much time on float stuff and, I think, we even not passing testsuite for float.

from wasmi.

pepyakin avatar pepyakin commented on May 14, 2024

It seems that there is no separate instruction in LLVM that acts as fneg: fsub 0, x is used to represent it. I guess we fine since both LLVM and wasm strives to be IEEE 754 compatible.

from wasmi.

pepyakin avatar pepyakin commented on May 14, 2024

Also, just in case you interested, in #72 I've enabled fp tests and they should pass now.

from wasmi.

CryZe avatar CryZe commented on May 14, 2024

While there is no separate instruction for it in LLVM, the reference manual specifically calls out that subtracting from 0 is not correct:

This differs from subtracting the operand value from negative zero

I don't know enough about floating point to be able to judge whether there's any actual difference, but is there anything stopping you from just implementing it as:

f32::from_bits(val.to_bits() ^ 0x8000_0000)

from wasmi.

pepyakin avatar pepyakin commented on May 14, 2024

Yeah, that's because the IEEE 754 tells the same!
I'm actually pretty not sure that fsub 0, x does something other than flipping the sign bit.

Personally, I'd perfer using f32::neg rather than bit-twiddling since it's cleaner (and maybe there is a chance that llvm might generate a better code?)

So before doing that change, I would like to be sure that this is actually a problem.

I think running the testsuite on a some exotic (fp-wise) arch such as MIPS would be enough to discover problems if they are actually present!

from wasmi.

pepyakin avatar pepyakin commented on May 14, 2024

After all we ended up with raw bit manipulation, see #87 !

from wasmi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.