1 // RUN: %clang_cc1 -fexperimental-new-pass-manager -ffreestanding %s -O0 -triple=x86_64-apple-darwin -target-cpu skylake-avx512 -emit-llvm -o - -Wall -Werror | FileCheck %s
2
3 #include <immintrin.h>
4
test_mm512_reduce_max_epi64(__m512i __W)5 long long test_mm512_reduce_max_epi64(__m512i __W){
6 // CHECK-LABEL: @test_mm512_reduce_max_epi64(
7 // CHECK: call i64 @llvm.vector.reduce.smax.v8i64(<8 x i64> %{{.*}})
8 return _mm512_reduce_max_epi64(__W);
9 }
10
test_mm512_reduce_max_epu64(__m512i __W)11 unsigned long long test_mm512_reduce_max_epu64(__m512i __W){
12 // CHECK-LABEL: @test_mm512_reduce_max_epu64(
13 // CHECK: call i64 @llvm.vector.reduce.umax.v8i64(<8 x i64> %{{.*}})
14 return _mm512_reduce_max_epu64(__W);
15 }
16
test_mm512_reduce_max_pd(__m512d __W,double ExtraAddOp)17 double test_mm512_reduce_max_pd(__m512d __W, double ExtraAddOp){
18 // CHECK-LABEL: @test_mm512_reduce_max_pd(
19 // CHECK-NOT: nnan
20 // CHECK: call nnan double @llvm.vector.reduce.fmax.v8f64(<8 x double> %{{.*}})
21 // CHECK-NOT: nnan
22 return _mm512_reduce_max_pd(__W) + ExtraAddOp;
23 }
24
test_mm512_reduce_min_epi64(__m512i __W)25 long long test_mm512_reduce_min_epi64(__m512i __W){
26 // CHECK-LABEL: @test_mm512_reduce_min_epi64(
27 // CHECK: call i64 @llvm.vector.reduce.smin.v8i64(<8 x i64> %{{.*}})
28 return _mm512_reduce_min_epi64(__W);
29 }
30
test_mm512_reduce_min_epu64(__m512i __W)31 unsigned long long test_mm512_reduce_min_epu64(__m512i __W){
32 // CHECK-LABEL: @test_mm512_reduce_min_epu64(
33 // CHECK: call i64 @llvm.vector.reduce.umin.v8i64(<8 x i64> %{{.*}})
34 return _mm512_reduce_min_epu64(__W);
35 }
36
test_mm512_reduce_min_pd(__m512d __W,double ExtraMulOp)37 double test_mm512_reduce_min_pd(__m512d __W, double ExtraMulOp){
38 // CHECK-LABEL: @test_mm512_reduce_min_pd(
39 // CHECK-NOT: nnan
40 // CHECK: call nnan double @llvm.vector.reduce.fmin.v8f64(<8 x double> %{{.*}})
41 // CHECK-NOT: nnan
42 return _mm512_reduce_min_pd(__W) * ExtraMulOp;
43 }
44
test_mm512_mask_reduce_max_epi64(__mmask8 __M,__m512i __W)45 long long test_mm512_mask_reduce_max_epi64(__mmask8 __M, __m512i __W){
46 // CHECK-LABEL: @test_mm512_mask_reduce_max_epi64(
47 // CHECK: bitcast i8 %{{.*}} to <8 x i1>
48 // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
49 // CHECK: call i64 @llvm.vector.reduce.smax.v8i64(<8 x i64> %{{.*}})
50 return _mm512_mask_reduce_max_epi64(__M, __W);
51 }
52
test_mm512_mask_reduce_max_epu64(__mmask8 __M,__m512i __W)53 unsigned long test_mm512_mask_reduce_max_epu64(__mmask8 __M, __m512i __W){
54 // CHECK-LABEL: @test_mm512_mask_reduce_max_epu64(
55 // CHECK: bitcast i8 %{{.*}} to <8 x i1>
56 // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
57 // CHECK: call i64 @llvm.vector.reduce.umax.v8i64(<8 x i64> %{{.*}})
58 return _mm512_mask_reduce_max_epu64(__M, __W);
59 }
60
test_mm512_mask_reduce_max_pd(__mmask8 __M,__m512d __W)61 double test_mm512_mask_reduce_max_pd(__mmask8 __M, __m512d __W){
62 // CHECK-LABEL: @test_mm512_mask_reduce_max_pd(
63 // CHECK: bitcast i8 %{{.*}} to <8 x i1>
64 // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
65 // CHECK: call nnan double @llvm.vector.reduce.fmax.v8f64(<8 x double> %{{.*}})
66 return _mm512_mask_reduce_max_pd(__M, __W);
67 }
68
test_mm512_mask_reduce_min_epi64(__mmask8 __M,__m512i __W)69 long long test_mm512_mask_reduce_min_epi64(__mmask8 __M, __m512i __W){
70 // CHECK-LABEL: @test_mm512_mask_reduce_min_epi64(
71 // CHECK: bitcast i8 %{{.*}} to <8 x i1>
72 // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
73 // CHECK: call i64 @llvm.vector.reduce.smin.v8i64(<8 x i64> %{{.*}})
74 return _mm512_mask_reduce_min_epi64(__M, __W);
75 }
76
test_mm512_mask_reduce_min_epu64(__mmask8 __M,__m512i __W)77 unsigned long long test_mm512_mask_reduce_min_epu64(__mmask8 __M, __m512i __W){
78 // CHECK-LABEL: @test_mm512_mask_reduce_min_epu64(
79 // CHECK: bitcast i8 %{{.*}} to <8 x i1>
80 // CHECK: select <8 x i1> %{{.*}}, <8 x i64> %{{.*}}, <8 x i64> %{{.*}}
81 // CHECK: call i64 @llvm.vector.reduce.umin.v8i64(<8 x i64> %{{.*}})
82 return _mm512_mask_reduce_min_epu64(__M, __W);
83 }
84
test_mm512_mask_reduce_min_pd(__mmask8 __M,__m512d __W)85 double test_mm512_mask_reduce_min_pd(__mmask8 __M, __m512d __W){
86 // CHECK-LABEL: @test_mm512_mask_reduce_min_pd(
87 // CHECK: bitcast i8 %{{.*}} to <8 x i1>
88 // CHECK: select <8 x i1> %{{.*}}, <8 x double> %{{.*}}, <8 x double> %{{.*}}
89 // CHECK: call nnan double @llvm.vector.reduce.fmin.v8f64(<8 x double> %{{.*}})
90 return _mm512_mask_reduce_min_pd(__M, __W);
91 }
92
test_mm512_reduce_max_epi32(__m512i __W)93 int test_mm512_reduce_max_epi32(__m512i __W){
94 // CHECK-LABEL: @test_mm512_reduce_max_epi32(
95 // CHECK: call i32 @llvm.vector.reduce.smax.v16i32(<16 x i32> %{{.*}})
96 return _mm512_reduce_max_epi32(__W);
97 }
98
test_mm512_reduce_max_epu32(__m512i __W)99 unsigned int test_mm512_reduce_max_epu32(__m512i __W){
100 // CHECK-LABEL: @test_mm512_reduce_max_epu32(
101 // CHECK: call i32 @llvm.vector.reduce.umax.v16i32(<16 x i32> %{{.*}})
102 return _mm512_reduce_max_epu32(__W);
103 }
104
test_mm512_reduce_max_ps(__m512 __W)105 float test_mm512_reduce_max_ps(__m512 __W){
106 // CHECK-LABEL: @test_mm512_reduce_max_ps(
107 // CHECK: call nnan float @llvm.vector.reduce.fmax.v16f32(<16 x float> %{{.*}})
108 return _mm512_reduce_max_ps(__W);
109 }
110
test_mm512_reduce_min_epi32(__m512i __W)111 int test_mm512_reduce_min_epi32(__m512i __W){
112 // CHECK-LABEL: @test_mm512_reduce_min_epi32(
113 // CHECK: call i32 @llvm.vector.reduce.smin.v16i32(<16 x i32> %{{.*}})
114 return _mm512_reduce_min_epi32(__W);
115 }
116
test_mm512_reduce_min_epu32(__m512i __W)117 unsigned int test_mm512_reduce_min_epu32(__m512i __W){
118 // CHECK-LABEL: @test_mm512_reduce_min_epu32(
119 // CHECK: call i32 @llvm.vector.reduce.umin.v16i32(<16 x i32> %{{.*}})
120 return _mm512_reduce_min_epu32(__W);
121 }
122
test_mm512_reduce_min_ps(__m512 __W)123 float test_mm512_reduce_min_ps(__m512 __W){
124 // CHECK-LABEL: @test_mm512_reduce_min_ps(
125 // CHECK: call nnan float @llvm.vector.reduce.fmin.v16f32(<16 x float> %{{.*}})
126 return _mm512_reduce_min_ps(__W);
127 }
128
test_mm512_mask_reduce_max_epi32(__mmask16 __M,__m512i __W)129 int test_mm512_mask_reduce_max_epi32(__mmask16 __M, __m512i __W){
130 // CHECK-LABEL: @test_mm512_mask_reduce_max_epi32(
131 // CHECK: bitcast i16 %{{.*}} to <16 x i1>
132 // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
133 // CHECK: call i32 @llvm.vector.reduce.smax.v16i32(<16 x i32> %{{.*}})
134 return _mm512_mask_reduce_max_epi32(__M, __W);
135 }
136
test_mm512_mask_reduce_max_epu32(__mmask16 __M,__m512i __W)137 unsigned int test_mm512_mask_reduce_max_epu32(__mmask16 __M, __m512i __W){
138 // CHECK-LABEL: @test_mm512_mask_reduce_max_epu32(
139 // CHECK: bitcast i16 %{{.*}} to <16 x i1>
140 // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
141 // CHECK: call i32 @llvm.vector.reduce.umax.v16i32(<16 x i32> %{{.*}})
142 return _mm512_mask_reduce_max_epu32(__M, __W);
143 }
144
test_mm512_mask_reduce_max_ps(__mmask16 __M,__m512 __W)145 float test_mm512_mask_reduce_max_ps(__mmask16 __M, __m512 __W){
146 // CHECK-LABEL: @test_mm512_mask_reduce_max_ps(
147 // CHECK: bitcast i16 %{{.*}} to <16 x i1>
148 // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
149 // CHECK: call nnan float @llvm.vector.reduce.fmax.v16f32(<16 x float> %{{.*}})
150 return _mm512_mask_reduce_max_ps(__M, __W);
151 }
152
test_mm512_mask_reduce_min_epi32(__mmask16 __M,__m512i __W)153 int test_mm512_mask_reduce_min_epi32(__mmask16 __M, __m512i __W){
154 // CHECK-LABEL: @test_mm512_mask_reduce_min_epi32(
155 // CHECK: bitcast i16 %{{.*}} to <16 x i1>
156 // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
157 // CHECK: call i32 @llvm.vector.reduce.smin.v16i32(<16 x i32> %{{.*}})
158 return _mm512_mask_reduce_min_epi32(__M, __W);
159 }
160
test_mm512_mask_reduce_min_epu32(__mmask16 __M,__m512i __W)161 unsigned int test_mm512_mask_reduce_min_epu32(__mmask16 __M, __m512i __W){
162 // CHECK-LABEL: @test_mm512_mask_reduce_min_epu32(
163 // CHECK: bitcast i16 %{{.*}} to <16 x i1>
164 // CHECK: select <16 x i1> %{{.*}}, <16 x i32> %{{.*}}, <16 x i32> %{{.*}}
165 // CHECK: call i32 @llvm.vector.reduce.umin.v16i32(<16 x i32> %{{.*}})
166 return _mm512_mask_reduce_min_epu32(__M, __W);
167 }
168
test_mm512_mask_reduce_min_ps(__mmask16 __M,__m512 __W)169 float test_mm512_mask_reduce_min_ps(__mmask16 __M, __m512 __W){
170 // CHECK-LABEL: @test_mm512_mask_reduce_min_ps(
171 // CHECK: bitcast i16 %{{.*}} to <16 x i1>
172 // CHECK: select <16 x i1> %{{.*}}, <16 x float> %{{.*}}, <16 x float> %{{.*}}
173 // CHECK: call nnan float @llvm.vector.reduce.fmin.v16f32(<16 x float> %{{.*}})
174 return _mm512_mask_reduce_min_ps(__M, __W);
175 }
176
177