Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize trunc instructions implementation
Browse files Browse the repository at this point in the history
chfast committed Aug 7, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent a265a7b commit a3c4df0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/fizzy/execute.cpp
Original file line number Diff line number Diff line change
@@ -332,11 +332,15 @@ inline bool trunc(OperandStack& stack) noexcept
using boundaries = trunc_boundaries<SrcT, DstT>;

const auto input = stack.top().as<SrcT>();
if (std::isnan(input) || input <= boundaries::lower || input >= boundaries::upper)
return false;

stack.top() = static_cast<DstT>(input);
return true;
if (input > boundaries::lower && input < boundaries::upper)
{
assert(!std::isnan(input));
assert(input != std::numeric_limits<SrcT>::infinity());
assert(input != -std::numeric_limits<SrcT>::infinity());
stack.top() = static_cast<DstT>(input);
return true;
}
return false;
}

template <typename DstT, typename SrcT = DstT>

0 comments on commit a3c4df0

Please sign in to comment.