Debian Codegraph @

clang/test/CIR/CodeGenBuiltins/X86/avx512f16c-builtins.c

raw
1 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512fp16 -target-feature +avx512f -target-feature +avx512vl -fclangir -emit-cir -o %t.cir -Wall -Werror -Wsign-conversion
2 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
3 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512fp16 -target-feature +avx512f -target-feature +avx512vl -fclangir -emit-llvm -o %t.ll -Wall -Werror -Wsign-conversion
4 // RUN: FileCheck --check-prefixes=LLVM --input-file=%t.ll %s
5 // RUN: %clang_cc1 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-linux -target-feature +avx512fp16 -target-feature +avx512f -target-feature +avx512vl -emit-llvm -o %t.ll -Wall -Werror -Wsign-conversion
6 // RUN: FileCheck --check-prefixes=OGCG --input-file=%t.ll %s
7
8 #include <immintrin.h>
9
10 __m128 test_vcvtph2ps_mask(__m128i a, __m128 src, __mmask8 k) {
11 // CIR-LABEL: cir.func no_inline dso_local @test_vcvtph2ps_mask
12 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !s16i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !s16i>
13 // CIR: %{{.*}} = cir.cast floating %{{.*}} : !cir.vector<4 x !cir.f16> -> !cir.vector<4 x !cir.float>
14 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !cir.int<s, 1>>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !cir.int<s, 1>>
15 // CIR: %{{.*}} = cir.vec.ternary(%{{.*}}, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.int<s, 1>>, !cir.vector<4 x !cir.float>
16
17 // LLVM-LABEL: @test_vcvtph2ps_mask
18 // LLVM: %{{.*}} = fpext <4 x half> %{{.*}} to <4 x float>
19 // LLVM: %{{.*}} = select <4 x i1> {{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}
20
21 // OGCG-LABEL: @test_vcvtph2ps_mask
22 // OGCG: %{{.*}} = fpext <4 x half> %{{.*}} to <4 x float>
23 // OGCG: %{{.*}} = select <4 x i1> {{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}
24 typedef short __v8hi __attribute__((__vector_size__(16)));
25 return __builtin_ia32_vcvtph2ps_mask((__v8hi)a, src, k);
26 }
27
28 __m256 test_vcvtph2ps256_mask(__m128i a, __m256 src, __mmask8 k) {
29 // CIR-LABEL: cir.func no_inline dso_local @test_vcvtph2ps256_mask
30 // CIR: %{{.*}} = cir.cast floating %{{.*}} : !cir.vector<8 x !cir.f16> -> !cir.vector<8 x !cir.float>
31 // CIR: %{{.*}} = cir.vec.ternary(%{{.*}}, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.int<s, 1>>, !cir.vector<8 x !cir.float>
32
33 // LLVM-LABEL: @test_vcvtph2ps256_mask
34 // LLVM: %{{.*}} = fpext <8 x half> %{{.*}} to <8 x float>
35 // LLVM: %{{.*}} = select <8 x i1> {{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}
36
37 // OGCG-LABEL: @test_vcvtph2ps256_mask
38 // OGCG: %{{.*}} = fpext <8 x half> %{{.*}} to <8 x float>
39 // OGCG: %{{.*}} = select <8 x i1> {{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}
40 typedef short __v8hi __attribute__((__vector_size__(16)));
41 return __builtin_ia32_vcvtph2ps256_mask((__v8hi)a, src, k);
42 }
43
44 __m512 test_vcvtph2ps512_mask(__m256i a, __m512 src, __mmask16 k) {
45 // CIR-LABEL: cir.func no_inline dso_local @test_vcvtph2ps512_mask
46 // CIR: %{{.*}} = cir.cast floating %{{.*}} : !cir.vector<16 x !cir.f16> -> !cir.vector<16 x !cir.float>
47 // CIR: %{{.*}} = cir.vec.ternary(%{{.*}}, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.int<s, 1>>, !cir.vector<16 x !cir.float>
48
49 // LLVM-LABEL: @test_vcvtph2ps512_mask
50 // LLVM: %{{.*}} = fpext <16 x half> %{{.*}} to <16 x float>
51 // LLVM: %{{.*}} = select <16 x i1> {{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
52
53 // OGCG-LABEL: @test_vcvtph2ps512_mask
54 // OGCG: %{{.*}} = fpext <16 x half> %{{.*}} to <16 x float>
55 // OGCG: %{{.*}} = select <16 x i1> {{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
56 typedef short __v16hi __attribute__((__vector_size__(32)));
57 return __builtin_ia32_vcvtph2ps512_mask((__v16hi)a, src, k, 4);
58 }
59
60 __m128 test_vcvtph2ps_maskz(__m128i a, __mmask8 k) {
61 // CIR-LABEL: cir.func no_inline dso_local @test_vcvtph2ps_maskz
62 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !s16i>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !s16i>
63 // CIR: %{{.*}} = cir.cast floating %{{.*}} : !cir.vector<4 x !cir.f16> -> !cir.vector<4 x !cir.float>
64 // CIR: %{{.*}} = cir.vec.shuffle(%{{.*}}, %{{.*}} : !cir.vector<8 x !cir.int<s, 1>>) [#cir.int<0> : !s32i, #cir.int<1> : !s32i, #cir.int<2> : !s32i, #cir.int<3> : !s32i] : !cir.vector<4 x !cir.int<s, 1>>
65 // CIR: %{{.*}} = cir.vec.ternary(%{{.*}}, %{{.*}}, %{{.*}}) : !cir.vector<4 x !cir.int<s, 1>>, !cir.vector<4 x !cir.float>
66
67 // LLVM-LABEL: @test_vcvtph2ps_maskz
68 // LLVM: %{{.*}} = fpext <4 x half> %{{.*}} to <4 x float>
69 // LLVM: %{{.*}} = select <4 x i1> {{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}
70
71 // OGCG-LABEL: @test_vcvtph2ps_maskz
72 // OGCG: %{{.*}} = fpext <4 x half> %{{.*}} to <4 x float>
73 // OGCG: %{{.*}} = select <4 x i1> {{.*}}, <4 x float> %{{.*}}, <4 x float> %{{.*}}
74 typedef short __v8hi __attribute__((__vector_size__(16)));
75 return __builtin_ia32_vcvtph2ps_mask((__v8hi)a, _mm_setzero_ps(), k);
76 }
77
78 __m256 test_vcvtph2ps256_maskz(__m128i a, __mmask8 k) {
79 // CIR-LABEL: cir.func no_inline dso_local @test_vcvtph2ps256_maskz
80 // CIR: %{{.*}} = cir.cast floating %{{.*}} : !cir.vector<8 x !cir.f16> -> !cir.vector<8 x !cir.float>
81 // CIR: %{{.*}} = cir.vec.ternary(%{{.*}}, %{{.*}}, %{{.*}}) : !cir.vector<8 x !cir.int<s, 1>>, !cir.vector<8 x !cir.float>
82
83 // LLVM-LABEL: @test_vcvtph2ps256_maskz
84 // LLVM: %{{.*}} = fpext <8 x half> %{{.*}} to <8 x float>
85 // LLVM: %{{.*}} = select <8 x i1> {{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}
86
87 // OGCG-LABEL: @test_vcvtph2ps256_maskz
88 // OGCG: %{{.*}} = fpext <8 x half> %{{.*}} to <8 x float>
89 // OGCG: %{{.*}} = select <8 x i1> {{.*}}, <8 x float> %{{.*}}, <8 x float> %{{.*}}
90 typedef short __v8hi __attribute__((__vector_size__(16)));
91 return __builtin_ia32_vcvtph2ps256_mask((__v8hi)a, _mm256_setzero_ps(), k);
92 }
93
94 __m512 test_vcvtph2ps512_maskz(__m256i a, __mmask16 k) {
95 // CIR-LABEL: cir.func no_inline dso_local @test_vcvtph2ps512_maskz
96 // CIR: %{{.*}} = cir.cast floating %{{.*}} : !cir.vector<16 x !cir.f16> -> !cir.vector<16 x !cir.float>
97 // CIR: %{{.*}} = cir.vec.ternary(%{{.*}}, %{{.*}}, %{{.*}}) : !cir.vector<16 x !cir.int<s, 1>>, !cir.vector<16 x !cir.float>
98
99 // LLVM-LABEL: @test_vcvtph2ps512_maskz
100 // LLVM: %{{.*}} = fpext <16 x half> %{{.*}} to <16 x float>
101 // LLVM: %{{.*}} = select <16 x i1> {{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
102
103 // OGCG-LABEL: @test_vcvtph2ps512_maskz
104 // OGCG: %{{.*}} = fpext <16 x half> %{{.*}} to <16 x float>
105 // OGCG: %{{.*}} = select <16 x i1> {{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
106 typedef short __v16hi __attribute__((__vector_size__(32)));
107 return __builtin_ia32_vcvtph2ps512_mask((__v16hi)a, _mm512_setzero_ps(), k, 4);
108 }
109
110 __m512 test_mm512_cvt_roundph_ps(__m256i a) {
111 // CIR-LABEL: cir.func no_inline dso_local @test_mm512_cvt_roundph_ps
112 // CIR: %{{.*}} = cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.512" %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}} : (!cir.vector<16 x !s16i>, !cir.vector<16 x !cir.float>, !u16i, !s32i) -> !cir.vector<16 x !cir.float>
113
114 // LLVM-LABEL: @test_mm512_cvt_roundph_ps
115 // LLVM: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512(<16 x i16> %{{.*}}, <16 x float> %{{.*}}, i16 -1, i32 8)
116
117 // OGCG-LABEL: @test_mm512_cvt_roundph_ps
118 // OGCG: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512(<16 x i16> %{{.*}}, <16 x float> zeroinitializer, i16 -1, i32 8)
119 typedef short __v16hi __attribute__((__vector_size__(32)));
120 return _mm512_cvt_roundph_ps((__v16hi)a, _MM_FROUND_NO_EXC);
121 }
122
123 __m512 test_mm512_mask_cvt_roundph_ps(__m512 w, __mmask16 u, __m256i a) {
124 // CIR-LABEL: cir.func no_inline dso_local @test_mm512_mask_cvt_roundph_ps
125 // CIR: %{{.*}} = cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.512" %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}} : (!cir.vector<16 x !s16i>, !cir.vector<16 x !cir.float>, !u16i, !s32i) -> !cir.vector<16 x !cir.float>
126
127 // LLVM-LABEL: @test_mm512_mask_cvt_roundph_ps
128 // LLVM: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512(<16 x i16> %{{.*}}, <16 x float> %{{.*}}, i16 %{{.*}}, i32 8)
129
130 // OGCG-LABEL: @test_mm512_mask_cvt_roundph_ps
131 // OGCG: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512(<16 x i16> %{{.*}}, <16 x float> %{{.*}}, i16 %{{.*}}, i32 8)
132 typedef short __v16hi __attribute__((__vector_size__(32)));
133 return _mm512_mask_cvt_roundph_ps(w, u, (__v16hi)a, _MM_FROUND_NO_EXC);
134 }
135
136 __m512 test_mm512_maskz_cvt_roundph_ps(__mmask16 u, __m256i a) {
137 // CIR-LABEL: cir.func no_inline dso_local @test_mm512_maskz_cvt_roundph_ps
138 // CIR: %{{.*}} = cir.call_llvm_intrinsic "x86.avx512.mask.vcvtph2ps.512" %{{.*}}, %{{.*}}, %{{.*}}, %{{.*}} : (!cir.vector<16 x !s16i>, !cir.vector<16 x !cir.float>, !u16i, !s32i) -> !cir.vector<16 x !cir.float>
139
140 // LLVM-LABEL: @test_mm512_maskz_cvt_roundph_ps
141 // LLVM: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512(<16 x i16> %{{.*}}, <16 x float> %{{.*}}, i16 %{{.*}}, i32 8)
142
143 // OGCG-LABEL: @test_mm512_maskz_cvt_roundph_ps
144 // OGCG: call <16 x float> @llvm.x86.avx512.mask.vcvtph2ps.512(<16 x i16> %{{.*}}, <16 x float> %{{.*}}, i16 %{{.*}}, i32 8)
145 typedef short __v16hi __attribute__((__vector_size__(32)));
146 return _mm512_maskz_cvt_roundph_ps(u, (__v16hi)a, _MM_FROUND_NO_EXC);
147 }