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