1 // REQUIRES: x86-registered-target
2 // RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -S -o -
3 #define __MM_MALLOC_H
4
5 #include <x86intrin.h>
6
7 // No warnings.
8 extern __m256i a;
bar(__m256i a)9 int __attribute__((target("avx"))) bar(__m256i a) {
10 return _mm256_extract_epi32(a, 3);
11 }
12
baz()13 int baz() {
14 return bar(a);
15 }
16
qq_avx(__m256i a)17 int __attribute__((target("avx"))) qq_avx(__m256i a) {
18 return _mm256_extract_epi32(a, 3);
19 }
20
qq_noavx()21 int qq_noavx() {
22 return 0;
23 }
24
25 extern __m256i a;
qq()26 int qq() {
27 if (__builtin_cpu_supports("avx"))
28 return qq_avx(a);
29 else
30 return qq_noavx();
31 }
32
33 // Test that fma and fma4 are both separately and combined valid for an fma intrinsic.
fma_1(__m128 a,__m128 b,__m128 c)34 __m128 __attribute__((target("fma"))) fma_1(__m128 a, __m128 b, __m128 c) {
35 return __builtin_ia32_vfmaddps(a, b, c);
36 }
37
fma_2(__m128 a,__m128 b,__m128 c)38 __m128 __attribute__((target("fma4"))) fma_2(__m128 a, __m128 b, __m128 c) {
39 return __builtin_ia32_vfmaddps(a, b, c);
40 }
41
fma_3(__m128 a,__m128 b,__m128 c)42 __m128 __attribute__((target("fma,fma4"))) fma_3(__m128 a, __m128 b, __m128 c) {
43 return __builtin_ia32_vfmaddps(a, b, c);
44 }
45
verifyfeaturestrings()46 void verifyfeaturestrings() {
47 (void)__builtin_cpu_supports("cmov");
48 (void)__builtin_cpu_supports("mmx");
49 (void)__builtin_cpu_supports("popcnt");
50 (void)__builtin_cpu_supports("sse");
51 (void)__builtin_cpu_supports("sse2");
52 (void)__builtin_cpu_supports("sse3");
53 (void)__builtin_cpu_supports("ssse3");
54 (void)__builtin_cpu_supports("sse4.1");
55 (void)__builtin_cpu_supports("sse4.2");
56 (void)__builtin_cpu_supports("avx");
57 (void)__builtin_cpu_supports("avx2");
58 (void)__builtin_cpu_supports("sse4a");
59 (void)__builtin_cpu_supports("fma4");
60 (void)__builtin_cpu_supports("xop");
61 (void)__builtin_cpu_supports("fma");
62 (void)__builtin_cpu_supports("avx512f");
63 (void)__builtin_cpu_supports("bmi");
64 (void)__builtin_cpu_supports("bmi2");
65 (void)__builtin_cpu_supports("aes");
66 (void)__builtin_cpu_supports("pclmul");
67 (void)__builtin_cpu_supports("avx512vl");
68 (void)__builtin_cpu_supports("avx512bw");
69 (void)__builtin_cpu_supports("avx512dq");
70 (void)__builtin_cpu_supports("avx512cd");
71 (void)__builtin_cpu_supports("avx512er");
72 (void)__builtin_cpu_supports("avx512pf");
73 (void)__builtin_cpu_supports("avx512vbmi");
74 (void)__builtin_cpu_supports("avx512ifma");
75 }
76