Skip to content

Commit

Permalink
fix issignalnan
Browse files Browse the repository at this point in the history
  • Loading branch information
kumarak committed Aug 24, 2021
1 parent 5e5dfa6 commit 6ce9b1c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions include/remill/Arch/Runtime/Operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -566,21 +566,19 @@ MAKE_ATOMIC(XorFetch, xor_and_fetch, ^)

#if !defined(issignaling)

ALWAYS_INLINE uint8_t issignaling(float32_t x) {
ALWAYS_INLINE bool issignaling(float32_t x) {
const nan32_t x_nan = {x};
return x_nan.exponent == 0xFFU && !x_nan.is_quiet_nan && x_nan.payload;
}

ALWAYS_INLINE uint8_t issignaling(float64_t x) {
ALWAYS_INLINE bool issignaling(float64_t x) {
const nan64_t x_nan = {x};
return x_nan.exponent == 0x7FFU && !x_nan.is_quiet_nan && x_nan.payload;
}

ALWAYS_INLINE uint8_t issignaling(float80_t x) {
// this casts to a float64_t on purpose -- since we know that
// it is almost certainly an IEEE 754 double which we can decompose
const nan64_t x_nan = {static_cast<float64_t>(x)};
return x_nan.exponent == 0x7FFFU && !(x_nan.is_quiet_nan) && x_nan.payload;
ALWAYS_INLINE bool issignaling(float80_t x) {
const nan80_t x_nan = {x};
return x_nan.exponent == 0x7FFFU && !x_nan.is_quiet_nan && x_nan.payload && x_nan.interger_bit;
}

#endif // !defined(issignaling)
Expand Down Expand Up @@ -652,17 +650,17 @@ ALWAYS_INLINE static uint8_t IsNaN(float80_t x) {
return static_cast<uint8_t>(FP_NAN == std::fpclassify(static_cast<native_float80_t>(x)));
}

ALWAYS_INLINE static uint8_t IsSignalingNaN(float32_t x) {
ALWAYS_INLINE static bool IsSignalingNaN(float32_t x) {
const nan32_t x_nan = {x};
return x_nan.exponent == 0xFFU && !x_nan.is_quiet_nan && x_nan.payload;
}

ALWAYS_INLINE static uint8_t IsSignalingNaN(float64_t x) {
ALWAYS_INLINE static bool IsSignalingNaN(float64_t x) {
const nan64_t x_nan = {x};
return x_nan.exponent == 0x7FFU && !x_nan.is_quiet_nan && x_nan.payload;
}

ALWAYS_INLINE static uint8_t IsSignalingNaN(float80_t x) {
ALWAYS_INLINE static bool IsSignalingNaN(float80_t x) {
const nan80_t x_nan = {x};
return x_nan.exponent == 0x7FFFU && !x_nan.is_quiet_nan && x_nan.payload && x_nan.interger_bit;
}
Expand Down

0 comments on commit 6ce9b1c

Please sign in to comment.