1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <sal/types.h>
11 #include <tools/simdsupport.hxx>
15 #include "test_cpu_runtime_detection_x86_checks.hxx"
17 /* WARNING: This file is compiled with AVX2 support, don't call
18 * any function without checking cpuid to check the CPU can actually
19 * handle it, and don't include any headers that contain templates
20 * or inline functions, which includes cppunit.
22 #ifdef LO_AVX2_AVAILABLE
23 #define CPPUNIT_ASSERT_EQUAL(a, b) ((a) == (b) ? (void)0 : abort())
26 void CpuRuntimeDetectionX86Checks::checkAVX2()
28 #ifdef LO_AVX2_AVAILABLE
29 __m256i a
= _mm256_set_epi64x(1, 4, 8, 3);
30 __m256i b
= _mm256_set_epi64x(2, 1, 1, 5);
31 __m256i c
= _mm256_xor_si256(a
, b
);
34 _mm256_storeu_si256(reinterpret_cast<__m256i
*>(&values
), c
);
36 CPPUNIT_ASSERT_EQUAL(sal_Int64(6), values
[0]);
37 CPPUNIT_ASSERT_EQUAL(sal_Int64(9), values
[1]);
38 CPPUNIT_ASSERT_EQUAL(sal_Int64(5), values
[2]);
39 CPPUNIT_ASSERT_EQUAL(sal_Int64(3), values
[3]);
41 __m256i d
= _mm256_set_epi64x(3, 5, 1, 0);
43 __m256i result
= _mm256_cmpeq_epi64(d
, c
);
47 _mm256_storeu_si256(reinterpret_cast<__m256i
*>(&compare
), result
);
49 CPPUNIT_ASSERT_EQUAL(sal_Int64(0), compare
[0]);
50 CPPUNIT_ASSERT_EQUAL(sal_Int64(0), compare
[1]);
51 CPPUNIT_ASSERT_EQUAL(sal_Int64(-1), compare
[2]);
52 CPPUNIT_ASSERT_EQUAL(sal_Int64(-1), compare
[3]);
56 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */