252
|
1 // RUN: mlir-opt %s -convert-vector-to-llvm='use-opaque-pointers=1' -split-input-file | FileCheck %s
|
|
2 // RUN: mlir-opt %s -convert-vector-to-llvm='reassociate-fp-reductions use-opaque-pointers=1' -split-input-file | FileCheck %s --check-prefix=REASSOC
|
221
|
3
|
|
4 // CHECK-LABEL: @reduce_add_f32(
|
|
5 // CHECK-SAME: %[[A:.*]]: vector<16xf32>)
|
|
6 // CHECK: %[[C:.*]] = llvm.mlir.constant(0.000000e+00 : f32) : f32
|
|
7 // CHECK: %[[V:.*]] = "llvm.intr.vector.reduce.fadd"(%[[C]], %[[A]])
|
252
|
8 // CHECK-SAME: <{reassoc = false}> : (f32, vector<16xf32>) -> f32
|
221
|
9 // CHECK: return %[[V]] : f32
|
|
10 //
|
|
11 // REASSOC-LABEL: @reduce_add_f32(
|
|
12 // REASSOC-SAME: %[[A:.*]]: vector<16xf32>)
|
|
13 // REASSOC: %[[C:.*]] = llvm.mlir.constant(0.000000e+00 : f32) : f32
|
|
14 // REASSOC: %[[V:.*]] = "llvm.intr.vector.reduce.fadd"(%[[C]], %[[A]])
|
252
|
15 // REASSOC-SAME: <{reassoc = true}> : (f32, vector<16xf32>) -> f32
|
221
|
16 // REASSOC: return %[[V]] : f32
|
|
17 //
|
236
|
18 func.func @reduce_add_f32(%arg0: vector<16xf32>) -> f32 {
|
|
19 %0 = vector.reduction <add>, %arg0 : vector<16xf32> into f32
|
221
|
20 return %0 : f32
|
|
21 }
|
|
22
|
252
|
23 // -----
|
|
24
|
221
|
25 // CHECK-LABEL: @reduce_mul_f32(
|
|
26 // CHECK-SAME: %[[A:.*]]: vector<16xf32>)
|
|
27 // CHECK: %[[C:.*]] = llvm.mlir.constant(1.000000e+00 : f32) : f32
|
|
28 // CHECK: %[[V:.*]] = "llvm.intr.vector.reduce.fmul"(%[[C]], %[[A]])
|
252
|
29 // CHECK-SAME: <{reassoc = false}> : (f32, vector<16xf32>) -> f32
|
221
|
30 // CHECK: return %[[V]] : f32
|
|
31 //
|
|
32 // REASSOC-LABEL: @reduce_mul_f32(
|
|
33 // REASSOC-SAME: %[[A:.*]]: vector<16xf32>)
|
|
34 // REASSOC: %[[C:.*]] = llvm.mlir.constant(1.000000e+00 : f32) : f32
|
|
35 // REASSOC: %[[V:.*]] = "llvm.intr.vector.reduce.fmul"(%[[C]], %[[A]])
|
252
|
36 // REASSOC-SAME: <{reassoc = true}> : (f32, vector<16xf32>) -> f32
|
221
|
37 // REASSOC: return %[[V]] : f32
|
|
38 //
|
236
|
39 func.func @reduce_mul_f32(%arg0: vector<16xf32>) -> f32 {
|
|
40 %0 = vector.reduction <mul>, %arg0 : vector<16xf32> into f32
|
221
|
41 return %0 : f32
|
|
42 }
|
252
|
43
|
|
44 // -----
|
|
45
|
|
46 func.func @masked_reduce_add_f32(%arg0: vector<16xf32>, %mask : vector<16xi1>) -> f32 {
|
|
47 %0 = vector.mask %mask { vector.reduction <add>, %arg0 : vector<16xf32> into f32 } : vector<16xi1> -> f32
|
|
48 return %0 : f32
|
|
49 }
|
|
50
|
|
51 // CHECK-LABEL: func.func @masked_reduce_add_f32(
|
|
52 // CHECK-SAME: %[[INPUT:.*]]: vector<16xf32>,
|
|
53 // CHECK-SAME: %[[MASK:.*]]: vector<16xi1>) -> f32 {
|
|
54 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(0.000000e+00 : f32) : f32
|
|
55 // CHECK: %[[VL:.*]] = llvm.mlir.constant(16 : i32) : i32
|
|
56 // CHECK: "llvm.intr.vp.reduce.fadd"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (f32, vector<16xf32>, vector<16xi1>, i32) -> f32
|
|
57
|
|
58
|
|
59 // -----
|
|
60
|
|
61 func.func @masked_reduce_mul_f32(%arg0: vector<16xf32>, %mask : vector<16xi1>) -> f32 {
|
|
62 %0 = vector.mask %mask { vector.reduction <mul>, %arg0 : vector<16xf32> into f32 } : vector<16xi1> -> f32
|
|
63 return %0 : f32
|
|
64 }
|
|
65
|
|
66 // CHECK-LABEL: func.func @masked_reduce_mul_f32(
|
|
67 // CHECK-SAME: %[[INPUT:.*]]: vector<16xf32>,
|
|
68 // CHECK-SAME: %[[MASK:.*]]: vector<16xi1>) -> f32 {
|
|
69 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(1.000000e+00 : f32) : f32
|
|
70 // CHECK: %[[VL:.*]] = llvm.mlir.constant(16 : i32) : i32
|
|
71 // CHECK: "llvm.intr.vp.reduce.fmul"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (f32, vector<16xf32>, vector<16xi1>, i32) -> f32
|
|
72
|
|
73
|
|
74 // -----
|
|
75
|
|
76 func.func @masked_reduce_minf_f32(%arg0: vector<16xf32>, %mask : vector<16xi1>) -> f32 {
|
|
77 %0 = vector.mask %mask { vector.reduction <minf>, %arg0 : vector<16xf32> into f32 } : vector<16xi1> -> f32
|
|
78 return %0 : f32
|
|
79 }
|
|
80
|
|
81 // CHECK-LABEL: func.func @masked_reduce_minf_f32(
|
|
82 // CHECK-SAME: %[[INPUT:.*]]: vector<16xf32>,
|
|
83 // CHECK-SAME: %[[MASK:.*]]: vector<16xi1>) -> f32 {
|
|
84 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(0xFFC00000 : f32) : f32
|
|
85 // CHECK: %[[VL:.*]] = llvm.mlir.constant(16 : i32) : i32
|
|
86 // CHECK: "llvm.intr.vp.reduce.fmin"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (f32, vector<16xf32>, vector<16xi1>, i32) -> f32
|
|
87
|
|
88 // -----
|
|
89
|
|
90 func.func @masked_reduce_maxf_f32(%arg0: vector<16xf32>, %mask : vector<16xi1>) -> f32 {
|
|
91 %0 = vector.mask %mask { vector.reduction <maxf>, %arg0 : vector<16xf32> into f32 } : vector<16xi1> -> f32
|
|
92 return %0 : f32
|
|
93 }
|
|
94
|
|
95 // CHECK-LABEL: func.func @masked_reduce_maxf_f32(
|
|
96 // CHECK-SAME: %[[INPUT:.*]]: vector<16xf32>,
|
|
97 // CHECK-SAME: %[[MASK:.*]]: vector<16xi1>) -> f32 {
|
|
98 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(0x7FC00000 : f32) : f32
|
|
99 // CHECK: %[[VL:.*]] = llvm.mlir.constant(16 : i32) : i32
|
|
100 // CHECK: "llvm.intr.vp.reduce.fmax"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (f32, vector<16xf32>, vector<16xi1>, i32) -> f32
|
|
101
|
|
102 // -----
|
|
103
|
|
104 func.func @masked_reduce_add_i8(%arg0: vector<32xi8>, %mask : vector<32xi1>) -> i8 {
|
|
105 %0 = vector.mask %mask { vector.reduction <add>, %arg0 : vector<32xi8> into i8 } : vector<32xi1> -> i8
|
|
106 return %0 : i8
|
|
107 }
|
|
108
|
|
109 // CHECK-LABEL: func.func @masked_reduce_add_i8(
|
|
110 // CHECK-SAME: %[[INPUT:.*]]: vector<32xi8>,
|
|
111 // CHECK-SAME: %[[MASK:.*]]: vector<32xi1>) -> i8 {
|
|
112 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(0 : i8) : i8
|
|
113 // CHECK: %[[VL:.*]] = llvm.mlir.constant(32 : i32) : i32
|
|
114 // CHECK: "llvm.intr.vp.reduce.add"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (i8, vector<32xi8>, vector<32xi1>, i32) -> i8
|
|
115
|
|
116
|
|
117 // -----
|
|
118
|
|
119 func.func @masked_reduce_mul_i8(%arg0: vector<32xi8>, %mask : vector<32xi1>) -> i8 {
|
|
120 %0 = vector.mask %mask { vector.reduction <mul>, %arg0 : vector<32xi8> into i8 } : vector<32xi1> -> i8
|
|
121 return %0 : i8
|
|
122 }
|
|
123
|
|
124 // CHECK-LABEL: func.func @masked_reduce_mul_i8(
|
|
125 // CHECK-SAME: %[[INPUT:.*]]: vector<32xi8>,
|
|
126 // CHECK-SAME: %[[MASK:.*]]: vector<32xi1>) -> i8 {
|
|
127 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(1 : i8) : i8
|
|
128 // CHECK: %[[VL:.*]] = llvm.mlir.constant(32 : i32) : i32
|
|
129 // CHECK: %[[VAL_4:.*]] = "llvm.intr.vp.reduce.mul"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (i8, vector<32xi8>, vector<32xi1>, i32) -> i8
|
|
130
|
|
131 // -----
|
|
132
|
|
133 func.func @masked_reduce_minui_i8(%arg0: vector<32xi8>, %mask : vector<32xi1>) -> i8 {
|
|
134 %0 = vector.mask %mask { vector.reduction <minui>, %arg0 : vector<32xi8> into i8 } : vector<32xi1> -> i8
|
|
135 return %0 : i8
|
|
136 }
|
|
137
|
|
138 // CHECK-LABEL: func.func @masked_reduce_minui_i8(
|
|
139 // CHECK-SAME: %[[INPUT:.*]]: vector<32xi8>,
|
|
140 // CHECK-SAME: %[[MASK:.*]]: vector<32xi1>) -> i8 {
|
|
141 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(-1 : i8) : i8
|
|
142 // CHECK: %[[VL:.*]] = llvm.mlir.constant(32 : i32) : i32
|
|
143 // CHECK: "llvm.intr.vp.reduce.umin"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (i8, vector<32xi8>, vector<32xi1>, i32) -> i8
|
|
144
|
|
145 // -----
|
|
146
|
|
147 func.func @masked_reduce_maxui_i8(%arg0: vector<32xi8>, %mask : vector<32xi1>) -> i8 {
|
|
148 %0 = vector.mask %mask { vector.reduction <maxui>, %arg0 : vector<32xi8> into i8 } : vector<32xi1> -> i8
|
|
149 return %0 : i8
|
|
150 }
|
|
151
|
|
152 // CHECK-LABEL: func.func @masked_reduce_maxui_i8(
|
|
153 // CHECK-SAME: %[[INPUT:.*]]: vector<32xi8>,
|
|
154 // CHECK-SAME: %[[MASK:.*]]: vector<32xi1>) -> i8 {
|
|
155 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(0 : i8) : i8
|
|
156 // CHECK: %[[VL:.*]] = llvm.mlir.constant(32 : i32) : i32
|
|
157 // CHECK: "llvm.intr.vp.reduce.umax"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (i8, vector<32xi8>, vector<32xi1>, i32) -> i8
|
|
158
|
|
159 // -----
|
|
160
|
|
161 func.func @masked_reduce_minsi_i8(%arg0: vector<32xi8>, %mask : vector<32xi1>) -> i8 {
|
|
162 %0 = vector.mask %mask { vector.reduction <minsi>, %arg0 : vector<32xi8> into i8 } : vector<32xi1> -> i8
|
|
163 return %0 : i8
|
|
164 }
|
|
165
|
|
166 // CHECK-LABEL: func.func @masked_reduce_minsi_i8(
|
|
167 // CHECK-SAME: %[[INPUT:.*]]: vector<32xi8>,
|
|
168 // CHECK-SAME: %[[MASK:.*]]: vector<32xi1>) -> i8 {
|
|
169 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(127 : i8) : i8
|
|
170 // CHECK: %[[VL:.*]] = llvm.mlir.constant(32 : i32) : i32
|
|
171 // CHECK: "llvm.intr.vp.reduce.smin"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (i8, vector<32xi8>, vector<32xi1>, i32) -> i8
|
|
172
|
|
173 // -----
|
|
174
|
|
175 func.func @masked_reduce_maxsi_i8(%arg0: vector<32xi8>, %mask : vector<32xi1>) -> i8 {
|
|
176 %0 = vector.mask %mask { vector.reduction <maxsi>, %arg0 : vector<32xi8> into i8 } : vector<32xi1> -> i8
|
|
177 return %0 : i8
|
|
178 }
|
|
179
|
|
180 // CHECK-LABEL: func.func @masked_reduce_maxsi_i8(
|
|
181 // CHECK-SAME: %[[INPUT:.*]]: vector<32xi8>,
|
|
182 // CHECK-SAME: %[[MASK:.*]]: vector<32xi1>) -> i8 {
|
|
183 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(-128 : i8) : i8
|
|
184 // CHECK: %[[VL:.*]] = llvm.mlir.constant(32 : i32) : i32
|
|
185 // CHECK: "llvm.intr.vp.reduce.smax"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (i8, vector<32xi8>, vector<32xi1>, i32) -> i8
|
|
186
|
|
187 // -----
|
|
188
|
|
189 func.func @masked_reduce_or_i8(%arg0: vector<32xi8>, %mask : vector<32xi1>) -> i8 {
|
|
190 %0 = vector.mask %mask { vector.reduction <or>, %arg0 : vector<32xi8> into i8 } : vector<32xi1> -> i8
|
|
191 return %0 : i8
|
|
192 }
|
|
193
|
|
194 // CHECK-LABEL: func.func @masked_reduce_or_i8(
|
|
195 // CHECK-SAME: %[[INPUT:.*]]: vector<32xi8>,
|
|
196 // CHECK-SAME: %[[MASK:.*]]: vector<32xi1>) -> i8 {
|
|
197 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(0 : i8) : i8
|
|
198 // CHECK: %[[VL:.*]] = llvm.mlir.constant(32 : i32) : i32
|
|
199 // CHECK: "llvm.intr.vp.reduce.or"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (i8, vector<32xi8>, vector<32xi1>, i32) -> i8
|
|
200
|
|
201
|
|
202 // -----
|
|
203
|
|
204 func.func @masked_reduce_and_i8(%arg0: vector<32xi8>, %mask : vector<32xi1>) -> i8 {
|
|
205 %0 = vector.mask %mask { vector.reduction <and>, %arg0 : vector<32xi8> into i8 } : vector<32xi1> -> i8
|
|
206 return %0 : i8
|
|
207 }
|
|
208
|
|
209 // CHECK-LABEL: func.func @masked_reduce_and_i8(
|
|
210 // CHECK-SAME: %[[INPUT:.*]]: vector<32xi8>,
|
|
211 // CHECK-SAME: %[[MASK:.*]]: vector<32xi1>) -> i8 {
|
|
212 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(-1 : i8) : i8
|
|
213 // CHECK: %[[VL:.*]] = llvm.mlir.constant(32 : i32) : i32
|
|
214 // CHECK: "llvm.intr.vp.reduce.and"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (i8, vector<32xi8>, vector<32xi1>, i32) -> i8
|
|
215
|
|
216 // -----
|
|
217
|
|
218 func.func @masked_reduce_xor_i8(%arg0: vector<32xi8>, %mask : vector<32xi1>) -> i8 {
|
|
219 %0 = vector.mask %mask { vector.reduction <xor>, %arg0 : vector<32xi8> into i8 } : vector<32xi1> -> i8
|
|
220 return %0 : i8
|
|
221 }
|
|
222
|
|
223 // CHECK-LABEL: func.func @masked_reduce_xor_i8(
|
|
224 // CHECK-SAME: %[[INPUT:.*]]: vector<32xi8>,
|
|
225 // CHECK-SAME: %[[MASK:.*]]: vector<32xi1>) -> i8 {
|
|
226 // CHECK: %[[NEUTRAL:.*]] = llvm.mlir.constant(0 : i8) : i8
|
|
227 // CHECK: %[[VL:.*]] = llvm.mlir.constant(32 : i32) : i32
|
|
228 // CHECK: "llvm.intr.vp.reduce.xor"(%[[NEUTRAL]], %[[INPUT]], %[[MASK]], %[[VL]]) : (i8, vector<32xi8>, vector<32xi1>, i32) -> i8
|
|
229
|
|
230
|