Add guard around specialization for bool, which is only currently implemented for SSE.

This commit is contained in:
Rasmus Munk Larsen 2020-05-19 16:21:56 -07:00
parent 8a7f360ec3
commit cc86a31e20

View File

@ -21,7 +21,7 @@ inline T REF_DIV(const T& a, const T& b) { return a / b;}
template <typename T> template <typename T>
inline T REF_ABS_DIFF(const T& a, const T& b) { return a>b ? a - b : b-a;} inline T REF_ABS_DIFF(const T& a, const T& b) { return a>b ? a - b : b-a;}
// Specializations for bool // Specializations for bool.
template <> template <>
inline bool REF_ADD(const bool& a, const bool& b) { return a || b;} inline bool REF_ADD(const bool& a, const bool& b) { return a || b;}
template <> template <>
@ -29,7 +29,6 @@ inline bool REF_SUB(const bool& a, const bool& b) { return a ^ b;}
template <> template <>
inline bool REF_MUL(const bool& a, const bool& b) { return a && b;} inline bool REF_MUL(const bool& a, const bool& b) { return a && b;}
template<typename FromScalar, typename FromPacket, typename ToScalar, typename ToPacket, bool CanCast = false> template<typename FromScalar, typename FromPacket, typename ToScalar, typename ToPacket, bool CanCast = false>
struct test_cast_helper; struct test_cast_helper;
@ -106,10 +105,14 @@ void packetmath_boolean_mask_ops()
CHECK_CWISE2_IF(true, internal::pcmp_eq, internal::pcmp_eq); CHECK_CWISE2_IF(true, internal::pcmp_eq, internal::pcmp_eq);
} }
// Packet16b representing bool does not support ptrue, pandnot or pcmp_eq, since the scalar path
// (for some compilers) compute the bitwise and with 0x1 of the results to keep the value in [0,1].
#ifdef EIGEN_PACKET_MATH_SSE_H
template<> template<>
void packetmath_boolean_mask_ops<bool, internal::Packet16b>() void packetmath_boolean_mask_ops<bool, internal::Packet16b>()
{ {
} }
#endif
template<typename Scalar,typename Packet> void packetmath() template<typename Scalar,typename Packet> void packetmath()
{ {