Fix inconsistency between ptrue and pcmp_* in HVX

This commit is contained in:
Cheng Wang 2025-08-09 19:32:30 +00:00 committed by Rasmus Munk Larsen
parent ddce1d7d12
commit 1c0048a08c

View File

@ -399,9 +399,26 @@ EIGEN_STRONG_INLINE Packet8f pnegate(const Packet8f& a) {
return pnegate_hvx(a);
}
template <HVXPacketSize T>
EIGEN_STRONG_INLINE HVXPacket<T> ptrue_hvx(const HVXPacket<T>& a) {
return HVXPacket<T>::Create(Q6_V_vsplat_R(0x3f800000));
}
template <>
EIGEN_STRONG_INLINE Packet32f ptrue(const Packet32f& a) {
return ptrue_hvx(a);
}
template <>
EIGEN_STRONG_INLINE Packet16f ptrue(const Packet16f& a) {
return ptrue_hvx(a);
}
template <>
EIGEN_STRONG_INLINE Packet8f ptrue(const Packet8f& a) {
return ptrue_hvx(a);
}
template <HVXPacketSize T>
EIGEN_STRONG_INLINE HVXPacket<T> pcmp_le_hvx(const HVXPacket<T>& a, const HVXPacket<T>& b) {
HVX_Vector v_true = Q6_V_vsplat_R(0x3f800000);
HVX_Vector v_true = ptrue(a).Get();
HVX_VectorPred pred = Q6_Q_vcmp_gt_VsfVsf(a.Get(), b.Get());
return HVXPacket<T>::Create(Q6_V_vmux_QVV(pred, Q6_V_vzero(), v_true));
}
@ -420,7 +437,7 @@ EIGEN_STRONG_INLINE Packet8f pcmp_le(const Packet8f& a, const Packet8f& b) {
template <HVXPacketSize T>
EIGEN_STRONG_INLINE HVXPacket<T> pcmp_eq_hvx(const HVXPacket<T>& a, const HVXPacket<T>& b) {
HVX_Vector v_true = Q6_V_vsplat_R(0x3f800000);
HVX_Vector v_true = ptrue(a).Get();
HVX_VectorPred pred = Q6_Q_vcmp_eq_VwVw(a.Get(), b.Get());
return HVXPacket<T>::Create(Q6_V_vmux_QVV(pred, v_true, Q6_V_vzero()));
}
@ -439,7 +456,7 @@ EIGEN_STRONG_INLINE Packet8f pcmp_eq(const Packet8f& a, const Packet8f& b) {
template <HVXPacketSize T>
EIGEN_STRONG_INLINE HVXPacket<T> pcmp_lt_hvx(const HVXPacket<T>& a, const HVXPacket<T>& b) {
HVX_Vector v_true = Q6_V_vsplat_R(0x3f800000);
HVX_Vector v_true = ptrue(a).Get();
HVX_VectorPred pred = Q6_Q_vcmp_gt_VsfVsf(b.Get(), a.Get());
return HVXPacket<T>::Create(Q6_V_vmux_QVV(pred, v_true, Q6_V_vzero()));
}
@ -458,7 +475,7 @@ EIGEN_STRONG_INLINE Packet8f pcmp_lt(const Packet8f& a, const Packet8f& b) {
template <HVXPacketSize T>
EIGEN_STRONG_INLINE HVXPacket<T> pcmp_lt_or_nan_hvx(const HVXPacket<T>& a, const HVXPacket<T>& b) {
HVX_Vector v_true = Q6_V_vsplat_R(0x3f800000);
HVX_Vector v_true = ptrue(a).Get();
HVX_VectorPred pred = Q6_Q_vcmp_gt_VsfVsf(b.Get(), a.Get());
return HVXPacket<T>::Create(Q6_V_vmux_QVV(pred, v_true, Q6_V_vzero()));
}