nss: upgrade to release 3.73
[LibreOffice.git] / tools / qa / cppunit / test_cpu_runtime_detection_AVX2_check.cxx
blobb5948223752c3b0ee9c4a236a2d6f471827035ab
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #include <sal/types.h>
11 #include <tools/simdsupport.hxx>
13 #include <cppunit/TestAssert.h>
14 #include <cppunit/TestFixture.h>
15 #include <cppunit/extensions/HelperMacros.h>
16 #include <cppunit/plugin/TestPlugIn.h>
18 #include "test_cpu_runtime_detection_x86_checks.hxx"
20 /* WARNING: This file is compiled with AVX2 support, don't call
21 * any function without checking cpuid to check the CPU can actually
22 * handle it.
24 void CpuRuntimeDetectionX86Checks::checkAVX2()
26 #ifdef LO_AVX2_AVAILABLE
27 __m256i a = _mm256_set_epi64x(1, 4, 8, 3);
28 __m256i b = _mm256_set_epi64x(2, 1, 1, 5);
29 __m256i c = _mm256_xor_si256(a, b);
31 sal_Int64 values[4];
32 _mm256_storeu_si256(reinterpret_cast<__m256i*>(&values), c);
34 CPPUNIT_ASSERT_EQUAL(sal_Int64(6), values[0]);
35 CPPUNIT_ASSERT_EQUAL(sal_Int64(9), values[1]);
36 CPPUNIT_ASSERT_EQUAL(sal_Int64(5), values[2]);
37 CPPUNIT_ASSERT_EQUAL(sal_Int64(3), values[3]);
39 __m256i d = _mm256_set_epi64x(3, 5, 1, 0);
41 __m256i result = _mm256_cmpeq_epi64(d, c);
43 // Compare equals
44 sal_Int64 compare[4];
45 _mm256_storeu_si256(reinterpret_cast<__m256i*>(&compare), result);
47 CPPUNIT_ASSERT_EQUAL(sal_Int64(0), compare[0]);
48 CPPUNIT_ASSERT_EQUAL(sal_Int64(0), compare[1]);
49 CPPUNIT_ASSERT_EQUAL(sal_Int64(-1), compare[2]);
50 CPPUNIT_ASSERT_EQUAL(sal_Int64(-1), compare[3]);
51 #endif
54 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */