core:ppc Several improvements on VSX(2)

* add v_float64x2 support to v_rotate_*
* treat float vector in v_check_any, vec_any_lt as int vector
* add test case for v_rotate_left
This commit is contained in:
Sayed Adel 2018-05-04 23:09:38 +00:00
parent 60e5e213fd
commit ed19da21ab
2 changed files with 35 additions and 15 deletions

View File

@ -589,7 +589,7 @@ inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b)
return _Tpvec(vec_sld(a.val, b.val, CV_SHIFT)); return _Tpvec(vec_sld(a.val, b.val, CV_SHIFT));
} }
#define OPENCV_IMPL_VSX_ROTATE_64(_Tpvec, suffix, rg1, rg2) \ #define OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, suffix, rg1, rg2) \
template<int imm> \ template<int imm> \
inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \ inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \
{ \ { \
@ -598,11 +598,13 @@ inline _Tpvec v_rotate_##suffix(const _Tpvec& a, const _Tpvec& b) \
return imm ? b : a; \ return imm ? b : a; \
} }
OPENCV_IMPL_VSX_ROTATE_64(v_int64x2, right, a, b) #define OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(_Tpvec) \
OPENCV_IMPL_VSX_ROTATE_64(v_uint64x2, right, a, b) OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, left, b, a) \
OPENCV_IMPL_VSX_ROTATE_64_2RG(_Tpvec, right, a, b)
OPENCV_IMPL_VSX_ROTATE_64(v_int64x2, left, b, a) OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(v_float64x2)
OPENCV_IMPL_VSX_ROTATE_64(v_uint64x2, left, b, a) OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(v_uint64x2)
OPENCV_IMPL_VSX_ROTATE_64_2RG_LR(v_int64x2)
/* Extract */ /* Extract */
template<int s, typename _Tpvec> template<int s, typename _Tpvec>
@ -716,7 +718,6 @@ inline int v_signmask(const v_uint64x2& a)
inline int v_signmask(const v_float64x2& a) inline int v_signmask(const v_float64x2& a)
{ return v_signmask(v_reinterpret_as_s64(a)); } { return v_signmask(v_reinterpret_as_s64(a)); }
template<typename _Tpvec> template<typename _Tpvec>
inline bool v_check_all(const _Tpvec& a) inline bool v_check_all(const _Tpvec& a)
{ return vec_all_lt(a.val, _Tpvec().val); } { return vec_all_lt(a.val, _Tpvec().val); }
@ -726,6 +727,10 @@ inline bool v_check_all(const v_uint16x8 &a)
{ return v_check_all(v_reinterpret_as_s16(a)); } { return v_check_all(v_reinterpret_as_s16(a)); }
inline bool v_check_all(const v_uint32x4& a) inline bool v_check_all(const v_uint32x4& a)
{ return v_check_all(v_reinterpret_as_s32(a)); } { return v_check_all(v_reinterpret_as_s32(a)); }
inline bool v_check_all(const v_float32x4& a)
{ return v_check_all(v_reinterpret_as_s32(a)); }
inline bool v_check_all(const v_float64x2& a)
{ return v_check_all(v_reinterpret_as_s64(a)); }
template<typename _Tpvec> template<typename _Tpvec>
inline bool v_check_any(const _Tpvec& a) inline bool v_check_any(const _Tpvec& a)
@ -736,6 +741,10 @@ inline bool v_check_any(const v_uint16x8 &a)
{ return v_check_any(v_reinterpret_as_s16(a)); } { return v_check_any(v_reinterpret_as_s16(a)); }
inline bool v_check_any(const v_uint32x4& a) inline bool v_check_any(const v_uint32x4& a)
{ return v_check_any(v_reinterpret_as_s32(a)); } { return v_check_any(v_reinterpret_as_s32(a)); }
inline bool v_check_any(const v_float32x4& a)
{ return v_check_any(v_reinterpret_as_s32(a)); }
inline bool v_check_any(const v_float64x2& a)
{ return v_check_any(v_reinterpret_as_s64(a)); }
////////// Other math ///////// ////////// Other math /////////

View File

@ -837,17 +837,28 @@ template<typename R> struct TheTest
Data<R> resC = v_rotate_right<s>(a); Data<R> resC = v_rotate_right<s>(a);
Data<R> resD = v_rotate_right<s>(a, b); Data<R> resD = v_rotate_right<s>(a, b);
Data<R> resE = v_rotate_left<s>(a);
Data<R> resF = v_rotate_left<s>(a, b);
for (int i = 0; i < R::nlanes; ++i) for (int i = 0; i < R::nlanes; ++i)
{ {
if (i + s >= R::nlanes) if (i + s >= R::nlanes)
{ {
EXPECT_EQ((LaneType)0, resC[i]); EXPECT_EQ((LaneType)0, resC[i]);
EXPECT_EQ(dataB[i - R::nlanes + s], resD[i]); EXPECT_EQ(dataB[i - R::nlanes + s], resD[i]);
EXPECT_EQ((LaneType)0, resE[i - R::nlanes + s]);
EXPECT_EQ(dataB[i], resF[i - R::nlanes + s]);
} }
else else
{
EXPECT_EQ(dataA[i + s], resC[i]); EXPECT_EQ(dataA[i + s], resC[i]);
} EXPECT_EQ(dataA[i + s], resD[i]);
EXPECT_EQ(dataA[i], resE[i + s]);
EXPECT_EQ(dataA[i], resF[i + s]);
}
}
return *this; return *this;
} }