core(SIMD): update int64 SSE constructor
authorAlexander Alekhin <alexander.a.alekhin@gmail.com>
Mon, 18 Oct 2021 07:15:15 +0000 (07:15 +0000)
committerAlexander Alekhin <alexander.a.alekhin@gmail.com>
Mon, 18 Oct 2021 18:59:40 +0000 (18:59 +0000)
modules/core/include/opencv2/core/hal/intrin_sse.hpp
modules/core/test/test_intrin_utils.hpp

index f4b43a2..2244717 100644 (file)
@@ -244,7 +244,13 @@ struct v_uint64x2
     explicit v_uint64x2(__m128i v) : val(v) {}
     v_uint64x2(uint64 v0, uint64 v1)
     {
+#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64)
+        val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1);
+#elif defined(__GNUC__)
+        val = _mm_setr_epi64((__m64)v0, (__m64)v1);
+#else
         val = _mm_setr_epi32((int)v0, (int)(v0 >> 32), (int)v1, (int)(v1 >> 32));
+#endif
     }
 
     uint64 get0() const
@@ -272,7 +278,13 @@ struct v_int64x2
     explicit v_int64x2(__m128i v) : val(v) {}
     v_int64x2(int64 v0, int64 v1)
     {
+#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64)
+        val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1);
+#elif defined(__GNUC__)
+        val = _mm_setr_epi64((__m64)v0, (__m64)v1);
+#else
         val = _mm_setr_epi32((int)v0, (int)(v0 >> 32), (int)v1, (int)(v1 >> 32));
+#endif
     }
 
     int64 get0() const
index 5c22caa..3f196f1 100644 (file)
@@ -373,6 +373,23 @@ template<typename R> struct TheTest
             EXPECT_EQ((LaneType)12, vx_setall_res2_[i]);
         }
 
+#if CV_SIMD_WIDTH == 16
+        {
+            uint64 a = CV_BIG_INT(0x7fffffffffffffff);
+            uint64 b = (uint64)CV_BIG_INT(0xcfffffffffffffff);
+            v_uint64x2 uint64_vec(a, b);
+            EXPECT_EQ(a, uint64_vec.get0());
+            EXPECT_EQ(b, v_extract_n<1>(uint64_vec));
+        }
+        {
+            int64 a = CV_BIG_INT(0x7fffffffffffffff);
+            int64 b = CV_BIG_INT(-1);
+            v_int64x2 int64_vec(a, b);
+            EXPECT_EQ(a, int64_vec.get0());
+            EXPECT_EQ(b, v_extract_n<1>(int64_vec));
+        }
+#endif
+
         return *this;
     }