Skip to content
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

Ensure stricter templates for helpers in execution #826

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions lib/fizzy/execute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,13 +335,11 @@ inline constexpr T popcnt(T value) noexcept
template <typename T>
T fabs(T value) noexcept = delete;

template <>
inline float fabs(float value) noexcept
{
return bit_cast<float>(bit_cast<uint32_t>(value) & F32AbsMask);
}

template <>
inline double fabs(double value) noexcept
{
return bit_cast<double>(bit_cast<uint64_t>(value) & F64AbsMask);
Expand All @@ -350,13 +348,11 @@ inline double fabs(double value) noexcept
template <typename T>
T fneg(T value) noexcept = delete;

template <>
inline float fneg(float value) noexcept
{
return bit_cast<float>(bit_cast<uint32_t>(value) ^ F32SignMask);
}

template <>
inline double fneg(double value) noexcept
{
return bit_cast<double>(bit_cast<uint64_t>(value) ^ F64SignMask);
Expand Down Expand Up @@ -461,18 +457,16 @@ inline T fmax(T a, T b) noexcept
return a < b ? b : a;
}

template <typename T>
T fcopysign(T a, T b) noexcept = delete;
template <typename T, typename U>
T fcopysign(T a, U b) noexcept = delete;

template <>
inline float fcopysign(float a, float b) noexcept
{
const auto a_u = bit_cast<uint32_t>(a);
const auto b_u = bit_cast<uint32_t>(b);
return bit_cast<float>((a_u & F32AbsMask) | (b_u & F32SignMask));
}

template <>
inline double fcopysign(double a, double b) noexcept
{
const auto a_u = bit_cast<uint64_t>(a);
Expand Down