diff options
author | Erik Schnetter <schnetter@gmail.com> | 2013-07-02 22:34:42 -0400 |
---|---|---|
committer | Erik Schnetter <schnetter@gmail.com> | 2013-07-02 22:34:42 -0400 |
commit | e4fbcb8815d919662b9c100e7e2aed1ab5599add (patch) | |
tree | 4737af6bf9d00d67de0258b936a0a18cd7d1c64a /vec_sse_float1.h | |
parent | 9545770072d5e3c4cc4fd2ad0bff37e8bb93d20f (diff) | |
download | vecmathlib-e4fbcb8815d919662b9c100e7e2aed1ab5599add.zip vecmathlib-e4fbcb8815d919662b9c100e7e2aed1ab5599add.tar.gz |
Correct isnan on x86; improve isnan on other architectures
Diffstat (limited to 'vec_sse_float1.h')
-rw-r--r-- | vec_sse_float1.h | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/vec_sse_float1.h b/vec_sse_float1.h index 12ab1ae..0e04555 100644 --- a/vec_sse_float1.h +++ b/vec_sse_float1.h @@ -426,15 +426,27 @@ namespace vecmathlib { intvec_t ilogb() const { int_t r = std::ilogb(v); - if (r == FP_ILOGB0) r = std::numeric_limits<int_t>::min(); - else if (r == FP_ILOGBNAN) r = std::numeric_limits<int_t>::max(); + typedef std::numeric_limits<int_t> NL; + if (FP_ILOGB0 == NL::min() and r == FP_ILOGB0) r = NL::min(); + else if (FP_ILOGBNAN == NL::max() and r == FP_ILOGBNAN) r = NL::max(); return r; } boolvec_t isfinite() const { return std::isfinite(v); } boolvec_t isinf() const { return std::isinf(v); } boolvec_t isnan() const { - return _mm_ucomineq_ss(from_float(v), from_float(v)); +#if defined VML_HAVE_NAN + // This is wrong: + // return _mm_ucomineq_ss(from_float(v), from_float(v)); + // This works: + // char r; + // __asm__("ucomiss %[v],%[v]; setp %[r]": [r]"=q"(r): [v]"x"(v)); + // return boolvec_t::scalar_t(r); + // This works as well: + return std::isnan(v); +#else + return BV(false); +#endif } boolvec_t isnormal() const { return std::isnormal(v); } realvec ldexp(int_t n) const { return std::ldexp(v, n); } |