-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement float->int trunc instructions #447
Conversation
Codecov Report
@@ Coverage Diff @@
## master #447 +/- ##
========================================
Coverage 99.51% 99.51%
========================================
Files 54 54
Lines 15153 15349 +196
========================================
+ Hits 15079 15275 +196
Misses 74 74 |
4255355
to
e2cb827
Compare
Please rebase. |
This comment has been minimized.
This comment has been minimized.
95e605e
to
c71fe26
Compare
5bcde1d
to
1de5c68
Compare
db2c82e
to
c0d90b6
Compare
707f100
to
167c41b
Compare
lib/fizzy/execute.cpp
Outdated
using boundaries = trunc_boundaries<SrcT, DstT>; | ||
|
||
const auto input = stack.top().as<SrcT>(); | ||
if (std::isnan(input) || input <= boundaries::lower || input >= boundaries::upper) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why doesn't this need to check for inf
/-inf
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because always: -inf <= boundaries::lower
and inf >= boundaries::upper
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, actually, this can be optimized :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if that is true (seemingly it is because the tests pass), we should have a static_assert here for that, so that anyone reading the code understands the rules of wasm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what assert you would like to have here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-inf <= boundaries::lower
inf >= boundaries::lower
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this does not make sense to me. Every value is >= -inf
.
stack.top() = static_cast<DstT>(input); | ||
return true; | ||
} | ||
return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After the optimisation I'd add assert(std::isnan(input) || input == inf || input == -inf);
so that it matches the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, added correct variants of these asserts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't want to stretch this too much, but can we also have the static_assert for inf vs. boundaries? Obviously we cannot make the nan-check compile time :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me otherwise.
So what now? |
Dunno, merge? |
The operator from the wasm spec is partial, i.e. it has some undefined results.
But, the execution spec requires to trap on operator's undefined result.