xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/portability/simd-intrinsics-x86.cpp (revision e8a3ddafe063c970df9c23e803812369abde4c82)
1 // RUN: %check_clang_tidy -std=c++11-or-later %s portability-simd-intrinsics %t -- \
2 // RUN:  -config='{CheckOptions: { \
3 // RUN:    portability-simd-intrinsics.Suggest: false \
4 // RUN:  }}' -- -target x86_64
5 // RUN: %check_clang_tidy -std=c++11,c++14,c++17 %s portability-simd-intrinsics -check-suffix=BEFORE-CXX20 %t -- \
6 // RUN:  -config='{CheckOptions: { \
7 // RUN:    portability-simd-intrinsics.Suggest: true \
8 // RUN:  }}' -- -target x86_64
9 // RUN: %check_clang_tidy -std=c++20-or-later %s portability-simd-intrinsics -check-suffix=CXX20 %t -- \
10 // RUN:  -config='{CheckOptions: { \
11 // RUN:    portability-simd-intrinsics.Suggest: true \
12 // RUN:  }}' -- -target x86_64
13 
14 typedef long long __m128i __attribute__((vector_size(16)));
15 typedef double __m256 __attribute__((vector_size(32)));
16 
17 __m128i _mm_add_epi32(__m128i, __m128i);
18 __m256 _mm256_load_pd(double const *);
19 void _mm256_store_pd(double *, __m256);
20 
21 int _mm_add_fake(int, int);
22 
X86()23 void X86() {
24   __m128i i0, i1;
25   __m256 d0;
26 
27   _mm_add_epi32(i0, i1);
28   // CHECK-MESSAGES-BEFORE-CXX20: :[[@LINE-1]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::experimental::simd objects [portability-simd-intrinsics]
29   // CHECK-MESSAGES-CXX20: :[[@LINE-2]]:3: warning: '_mm_add_epi32' can be replaced by operator+ on std::simd objects [portability-simd-intrinsics]
30   // CHECK-MESSAGES: :[[@LINE-3]]:3: warning: '_mm_add_epi32' is a non-portable x86_64 intrinsic function [portability-simd-intrinsics]
31   d0 = _mm256_load_pd(0);
32   _mm256_store_pd(0, d0);
33 
34   _mm_add_fake(0, 1);
35 }
36