Skip to content

Commit 3f37be5

Browse files
committed
core: fix compilation of intrinsic code
1 parent f8ad289 commit 3f37be5

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

modules/core/include/opencv2/core/hal/intrin_sse.hpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,24 +1024,28 @@ OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint64x2, v_int64x2, epi64, v_srai_epi64)
10241024
template<int imm, typename _Tpvec>
10251025
inline _Tpvec v_rotate_right(const _Tpvec &a)
10261026
{
1027-
return _Tpvec(_mm_srli_si128(a.val, imm*(sizeof(typename _Tpvec::lane_type))));
1027+
enum { CV_SHIFT = imm*(sizeof(typename _Tpvec::lane_type)) };
1028+
return _Tpvec(_mm_srli_si128(a.val, CV_SHIFT));
10281029
}
10291030
template<int imm, typename _Tpvec>
10301031
inline _Tpvec v_rotate_left(const _Tpvec &a)
10311032
{
1032-
return _Tpvec(_mm_slli_si128(a.val, imm*(sizeof(typename _Tpvec::lane_type))));
1033+
enum { CV_SHIFT = imm*(sizeof(typename _Tpvec::lane_type)) };
1034+
return _Tpvec(_mm_slli_si128(a.val, CV_SHIFT));
10331035
}
10341036
template<int imm, typename _Tpvec>
10351037
inline _Tpvec v_rotate_right(const _Tpvec &a, const _Tpvec &b)
10361038
{
1037-
const int cWidth = sizeof(typename _Tpvec::lane_type);
1038-
return _Tpvec(_mm_or_si128(_mm_srli_si128(a.val, imm*cWidth), _mm_slli_si128(b.val, (16 - imm*cWidth))));
1039+
enum { CV_SHIFT1 = imm*(sizeof(typename _Tpvec::lane_type)) };
1040+
enum { CV_SHIFT2 = 16 - imm*(sizeof(typename _Tpvec::lane_type)) };
1041+
return _Tpvec(_mm_or_si128(_mm_srli_si128(a.val, CV_SHIFT1), _mm_slli_si128(b.val, CV_SHIFT2)));
10391042
}
10401043
template<int imm, typename _Tpvec>
10411044
inline _Tpvec v_rotate_left(const _Tpvec &a, const _Tpvec &b)
10421045
{
1043-
const int cWidth = sizeof(typename _Tpvec::lane_type);
1044-
return _Tpvec(_mm_or_si128(_mm_slli_si128(a.val, imm*cWidth), _mm_srli_si128(b.val, (16 - imm*cWidth))));
1046+
enum { CV_SHIFT1 = imm*(sizeof(typename _Tpvec::lane_type)) };
1047+
enum { CV_SHIFT2 = 16 - imm*(sizeof(typename _Tpvec::lane_type)) };
1048+
return _Tpvec(_mm_or_si128(_mm_slli_si128(a.val, CV_SHIFT1), _mm_srli_si128(b.val, CV_SHIFT2)));
10451049
}
10461050

10471051
#define OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(_Tpvec, _Tp) \

modules/core/include/opencv2/core/hal/intrin_vsx.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -634,19 +634,19 @@ OPENCV_IMPL_VSX_ROTATE_LR(v_int64x2, vec_dword2)
634634
template<int imm, typename _Tpvec>
635635
inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b)
636636
{
637-
const int wd = imm * sizeof(typename _Tpvec::lane_type);
638-
if (wd == 0)
637+
enum { CV_SHIFT = 16 - imm * (sizeof(typename _Tpvec::lane_type)) };
638+
if (CV_SHIFT == 16)
639639
return a;
640-
return _Tpvec(vec_sld(b.val, a.val, 16 - wd));
640+
return _Tpvec(vec_sld(b.val, a.val, CV_SHIFT));
641641
}
642642

643643
template<int imm, typename _Tpvec>
644644
inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b)
645645
{
646-
const int wd = imm * sizeof(typename _Tpvec::lane_type);
647-
if (wd == 16)
646+
enum { CV_SHIFT = imm * (sizeof(typename _Tpvec::lane_type)) };
647+
if (CV_SHIFT == 16)
648648
return b;
649-
return _Tpvec(vec_sld(a.val, b.val, wd));
649+
return _Tpvec(vec_sld(a.val, b.val, CV_SHIFT));
650650
}
651651

652652
#define OPENCV_IMPL_VSX_ROTATE_64(_Tpvec, suffix, rg1, rg2) \

0 commit comments

Comments
 (0)