From 3f37be5a304ca86049524899a64abb8e9f61ac3e Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 22 Nov 2017 15:52:40 +0300 Subject: [PATCH] core: fix compilation of intrinsic code --- .../core/include/opencv2/core/hal/intrin_sse.hpp | 16 ++++++++++------ .../core/include/opencv2/core/hal/intrin_vsx.hpp | 12 ++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/modules/core/include/opencv2/core/hal/intrin_sse.hpp b/modules/core/include/opencv2/core/hal/intrin_sse.hpp index 637d49282e..0e740f6418 100644 --- a/modules/core/include/opencv2/core/hal/intrin_sse.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_sse.hpp @@ -1024,24 +1024,28 @@ OPENCV_HAL_IMPL_SSE_SHIFT_OP(v_uint64x2, v_int64x2, epi64, v_srai_epi64) template inline _Tpvec v_rotate_right(const _Tpvec &a) { - return _Tpvec(_mm_srli_si128(a.val, imm*(sizeof(typename _Tpvec::lane_type)))); + enum { CV_SHIFT = imm*(sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(_mm_srli_si128(a.val, CV_SHIFT)); } template inline _Tpvec v_rotate_left(const _Tpvec &a) { - return _Tpvec(_mm_slli_si128(a.val, imm*(sizeof(typename _Tpvec::lane_type)))); + enum { CV_SHIFT = imm*(sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(_mm_slli_si128(a.val, CV_SHIFT)); } template inline _Tpvec v_rotate_right(const _Tpvec &a, const _Tpvec &b) { - const int cWidth = sizeof(typename _Tpvec::lane_type); - return _Tpvec(_mm_or_si128(_mm_srli_si128(a.val, imm*cWidth), _mm_slli_si128(b.val, (16 - imm*cWidth)))); + enum { CV_SHIFT1 = imm*(sizeof(typename _Tpvec::lane_type)) }; + enum { CV_SHIFT2 = 16 - imm*(sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(_mm_or_si128(_mm_srli_si128(a.val, CV_SHIFT1), _mm_slli_si128(b.val, CV_SHIFT2))); } template inline _Tpvec v_rotate_left(const _Tpvec &a, const _Tpvec &b) { - const int cWidth = sizeof(typename _Tpvec::lane_type); - return _Tpvec(_mm_or_si128(_mm_slli_si128(a.val, imm*cWidth), _mm_srli_si128(b.val, (16 - imm*cWidth)))); + enum { CV_SHIFT1 = imm*(sizeof(typename _Tpvec::lane_type)) }; + enum { CV_SHIFT2 = 16 - imm*(sizeof(typename _Tpvec::lane_type)) }; + return _Tpvec(_mm_or_si128(_mm_slli_si128(a.val, CV_SHIFT1), _mm_srli_si128(b.val, CV_SHIFT2))); } #define OPENCV_HAL_IMPL_SSE_LOADSTORE_INT_OP(_Tpvec, _Tp) \ diff --git a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp index c8fa8ed5ce..446a1ca245 100644 --- a/modules/core/include/opencv2/core/hal/intrin_vsx.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_vsx.hpp @@ -634,19 +634,19 @@ OPENCV_IMPL_VSX_ROTATE_LR(v_int64x2, vec_dword2) template inline _Tpvec v_rotate_right(const _Tpvec& a, const _Tpvec& b) { - const int wd = imm * sizeof(typename _Tpvec::lane_type); - if (wd == 0) + enum { CV_SHIFT = 16 - imm * (sizeof(typename _Tpvec::lane_type)) }; + if (CV_SHIFT == 16) return a; - return _Tpvec(vec_sld(b.val, a.val, 16 - wd)); + return _Tpvec(vec_sld(b.val, a.val, CV_SHIFT)); } template inline _Tpvec v_rotate_left(const _Tpvec& a, const _Tpvec& b) { - const int wd = imm * sizeof(typename _Tpvec::lane_type); - if (wd == 16) + enum { CV_SHIFT = imm * (sizeof(typename _Tpvec::lane_type)) }; + if (CV_SHIFT == 16) return b; - return _Tpvec(vec_sld(a.val, b.val, wd)); + return _Tpvec(vec_sld(a.val, b.val, CV_SHIFT)); } #define OPENCV_IMPL_VSX_ROTATE_64(_Tpvec, suffix, rg1, rg2) \ -- GitLab