@@ -14,30 +14,28 @@ func.func @transfer_read_write_1d(%A : memref<?xf32>, %base: index) -> vector<17
14
14
// CHECK-LABEL: func @transfer_read_write_1d
15
15
// CHECK-SAME: %[[MEM:.*]]: memref<?xf32>,
16
16
// CHECK-SAME: %[[BASE:.*]]: index) -> vector<17xf32>
17
- // CHECK: %[[C7:.*]] = arith.constant 7.0
18
- //
19
- // 1. Let dim be the memref dimension, compute the in-bound index (dim - offset)
20
- // CHECK: %[[C0:.*]] = arith.constant 0 : index
21
- // CHECK: %[[DIM:.*]] = memref.dim %[[MEM]], %[[C0]] : memref<?xf32>
22
- // CHECK: %[[BOUND:.*]] = arith.subi %[[DIM]], %[[BASE]] : index
17
+ // 1. Create pass-through vector.
18
+ // CHECK-DAG: %[[PASS_THROUGH:.*]] = arith.constant dense<7.000000e+00> : vector<17xf32>
23
19
//
24
20
// 2. Create a vector with linear indices [ 0 .. vector_length - 1 ].
25
- // CHECK: %[[linearIndex:.*]] = arith.constant dense
21
+ // CHECK-DAG : %[[linearIndex:.*]] = arith.constant dense
26
22
// CHECK-SAME: <[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]> : vector<17x[[$IDX_TYPE]]>
27
23
//
28
- // 3. Create bound vector to compute in-bound mask:
24
+ // 3. Let dim be the memref dimension, compute the in-bound index (dim - offset)
25
+ // CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index
26
+ // CHECK: %[[DIM:.*]] = memref.dim %[[MEM]], %[[C0]] : memref<?xf32>
27
+ // CHECK: %[[BOUND:.*]] = arith.subi %[[DIM]], %[[BASE]] : index
28
+ //
29
+ // 4. Create bound vector to compute in-bound mask:
29
30
// [ 0 .. vector_length - 1 ] < [ dim - offset .. dim - offset ]
30
31
// CHECK: %[[btrunc:.*]] = arith.index_cast %[[BOUND]] :
31
32
// CMP32-SAME: index to i32
32
33
// CMP64-SAME: index to i64
33
34
// CHECK: %[[boundVecInsert:.*]] = llvm.insertelement %[[btrunc]]
34
35
// CHECK: %[[boundVect:.*]] = llvm.shufflevector %[[boundVecInsert]]
35
- // CHECK: %[[mask:.*]] = arith.cmpi slt , %[[linearIndex ]], %[[boundVect ]] : vector<17x[[$IDX_TYPE]]>
36
+ // CHECK: %[[mask:.*]] = arith.cmpi sgt , %[[boundVect ]], %[[linearIndex ]] : vector<17x[[$IDX_TYPE]]>
36
37
// CMP64-SAME: : vector<17xi64>
37
38
//
38
- // 4. Create pass-through vector.
39
- // CHECK: %[[PASS_THROUGH:.*]] = arith.constant dense<7.{{.*}}> : vector<17xf32>
40
- //
41
39
// 5. Bitcast to vector form.
42
40
// CHECK: %[[gep:.*]] = llvm.getelementptr %{{.*}} :
43
41
// CHECK-SAME: (!llvm.ptr, i64) -> !llvm.ptr, f32
@@ -48,28 +46,23 @@ func.func @transfer_read_write_1d(%A : memref<?xf32>, %base: index) -> vector<17
48
46
// CHECK-SAME: -> vector<17xf32>
49
47
//
50
48
// 1. Let dim be the memref dimension, compute the in-bound index (dim - offset)
51
- // CHECK: %[[C0_b:.*]] = arith.constant 0 : index
52
- // CHECK: %[[DIM_b:.*]] = memref.dim %[[MEM]], %[[C0_b]] : memref<?xf32>
49
+ // CHECK: %[[DIM_b:.*]] = memref.dim %[[MEM]], %[[C0]] : memref<?xf32>
53
50
// CHECK: %[[BOUND_b:.*]] = arith.subi %[[DIM_b]], %[[BASE]] : index
54
51
//
55
- // 2. Create a vector with linear indices [ 0 .. vector_length - 1 ].
56
- // CHECK: %[[linearIndex_b:.*]] = arith.constant dense
57
- // CHECK-SAME: <[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]> : vector<17x[[$IDX_TYPE]]>
58
- //
59
- // 3. Create bound vector to compute in-bound mask:
52
+ // 2. Create bound vector to compute in-bound mask:
60
53
// [ 0 .. vector_length - 1 ] < [ dim - offset .. dim - offset ]
61
54
// CHECK: %[[btrunc_b:.*]] = arith.index_cast %[[BOUND_b]]
62
55
// CMP32-SAME: index to i32
63
56
// CHECK: %[[boundVecInsert_b:.*]] = llvm.insertelement %[[btrunc_b]]
64
57
// CHECK: %[[boundVect_b:.*]] = llvm.shufflevector %[[boundVecInsert_b]]
65
- // CHECK: %[[mask_b:.*]] = arith.cmpi slt , %[[linearIndex_b ]],
66
- // CHECK-SAME: %[[boundVect_b ]] : vector<17x[[$IDX_TYPE]]>
58
+ // CHECK: %[[mask_b:.*]] = arith.cmpi sgt , %[[boundVect_b ]],
59
+ // CHECK-SAME: %[[linearIndex ]] : vector<17x[[$IDX_TYPE]]>
67
60
//
68
- // 4 . Bitcast to vector form.
61
+ // 3 . Bitcast to vector form.
69
62
// CHECK: %[[gep_b:.*]] = llvm.getelementptr {{.*}} :
70
63
// CHECK-SAME: (!llvm.ptr, i64) -> !llvm.ptr, f32
71
64
//
72
- // 5 . Rewrite as a masked write.
65
+ // 4 . Rewrite as a masked write.
73
66
// CHECK: llvm.intr.masked.store %[[loaded]], %[[gep_b]], %[[mask_b]]
74
67
// CHECK-SAME: {alignment = 4 : i32} :
75
68
// CHECK-SAME: vector<17xf32>, vector<17xi1> into !llvm.ptr
@@ -87,27 +80,25 @@ func.func @transfer_read_write_1d_scalable(%A : memref<?xf32>, %base: index) ->
87
80
// CHECK-LABEL: func @transfer_read_write_1d_scalable
88
81
// CHECK-SAME: %[[MEM:.*]]: memref<?xf32>,
89
82
// CHECK-SAME: %[[BASE:.*]]: index) -> vector<[17]xf32>
90
- // CHECK: %[[C7:.*]] = arith.constant 7.0
83
+ // 1. Create pass-through vector.
84
+ // CHECK-DAG: %[[PASS_THROUGH:.*]] = arith.constant dense<7.000000e+00> : vector<[17]xf32>
91
85
//
92
- // 1 . Let dim be the memref dimension, compute the in-bound index (dim - offset)
93
- // CHECK: %[[C0:.*]] = arith.constant 0 : index
86
+ // 2 . Let dim be the memref dimension, compute the in-bound index (dim - offset)
87
+ // CHECK-DAG : %[[C0:.*]] = arith.constant 0 : index
94
88
// CHECK: %[[DIM:.*]] = memref.dim %[[MEM]], %[[C0]] : memref<?xf32>
95
89
// CHECK: %[[BOUND:.*]] = arith.subi %[[DIM]], %[[BASE]] : index
96
90
//
97
- // 2 . Create a vector with linear indices [ 0 .. vector_length - 1 ].
91
+ // 3 . Create a vector with linear indices [ 0 .. vector_length - 1 ].
98
92
// CHECK: %[[linearIndex:.*]] = llvm.intr.stepvector : vector<[17]x[[$IDX_TYPE]]>
99
93
//
100
- // 3 . Create bound vector to compute in-bound mask:
94
+ // 4 . Create bound vector to compute in-bound mask:
101
95
// [ 0 .. vector_length - 1 ] < [ dim - offset .. dim - offset ]
102
96
// CHECK: %[[btrunc:.*]] = arith.index_cast %[[BOUND]] : index to [[$IDX_TYPE]]
103
97
// CHECK: %[[boundVecInsert:.*]] = llvm.insertelement %[[btrunc]]
104
98
// CHECK: %[[boundVect:.*]] = llvm.shufflevector %[[boundVecInsert]]
105
99
// CHECK: %[[mask:.*]] = arith.cmpi slt, %[[linearIndex]], %[[boundVect]]
106
100
// CHECK-SAME: : vector<[17]x[[$IDX_TYPE]]>
107
101
//
108
- // 4. Create pass-through vector.
109
- // CHECK: %[[PASS_THROUGH:.*]] = arith.constant dense<7.{{.*}}> : vector<[17]xf32>
110
- //
111
102
// 5. Bitcast to vector form.
112
103
// CHECK: %[[gep:.*]] = llvm.getelementptr %{{.*}} :
113
104
// CHECK-SAME: (!llvm.ptr, i64) -> !llvm.ptr, f32
@@ -118,8 +109,7 @@ func.func @transfer_read_write_1d_scalable(%A : memref<?xf32>, %base: index) ->
118
109
// CHECK-SAME: -> vector<[17]xf32>
119
110
//
120
111
// 1. Let dim be the memref dimension, compute the in-bound index (dim - offset)
121
- // CHECK: %[[C0_b:.*]] = arith.constant 0 : index
122
- // CHECK: %[[DIM_b:.*]] = memref.dim %[[MEM]], %[[C0_b]] : memref<?xf32>
112
+ // CHECK: %[[DIM_b:.*]] = memref.dim %[[MEM]], %[[C0]] : memref<?xf32>
123
113
// CHECK: %[[BOUND_b:.*]] = arith.subi %[[DIM_b]], %[[BASE]] : index
124
114
//
125
115
// 2. Create a vector with linear indices [ 0 .. vector_length - 1 ].
@@ -197,23 +187,23 @@ func.func @transfer_read_2d_to_1d(%A : memref<?x?xf32>, %base0: index, %base1: i
197
187
}
198
188
// CHECK-LABEL: func @transfer_read_2d_to_1d
199
189
// CHECK-SAME: %[[BASE_0:[a-zA-Z0-9]*]]: index, %[[BASE_1:[a-zA-Z0-9]*]]: index) -> vector<17xf32>
200
- // CHECK: %[[c1:.*]] = arith.constant 1 : index
190
+ //
191
+ // Create a vector with linear indices [ 0 .. vector_length - 1 ].
192
+ // CHECK-DAG: %[[linearIndex:.*]] = arith.constant dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]> :
193
+ // CHECK-SAME: vector<17x[[$IDX_TYPE]]>
194
+ //
195
+ // CHECK-DAG: %[[c1:.*]] = arith.constant 1 : index
201
196
// CHECK: %[[DIM:.*]] = memref.dim %{{.*}}, %[[c1]] : memref<?x?xf32>
202
197
//
203
198
// Compute the in-bound index (dim - offset)
204
199
// CHECK: %[[BOUND:.*]] = arith.subi %[[DIM]], %[[BASE_1]] : index
205
200
//
206
- // Create a vector with linear indices [ 0 .. vector_length - 1 ].
207
- // CHECK: %[[linearIndex:.*]] = arith.constant dense
208
- // CHECK-SAME: <[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]> :
209
- // CHECK-SAME: vector<17x[[$IDX_TYPE]]>
210
- //
211
201
// Create bound vector to compute in-bound mask:
212
202
// [ 0 .. vector_length - 1 ] < [ dim - offset .. dim - offset ]
213
203
// CHECK: %[[btrunc:.*]] = arith.index_cast %[[BOUND]] : index to [[$IDX_TYPE]]
214
204
// CHECK: %[[boundVecInsert:.*]] = llvm.insertelement %[[btrunc]]
215
205
// CHECK: %[[boundVect:.*]] = llvm.shufflevector %[[boundVecInsert]]
216
- // CHECK: %[[mask:.*]] = arith.cmpi slt , %[[linearIndex ]], %[[boundVect ]]
206
+ // CHECK: %[[mask:.*]] = arith.cmpi sgt , %[[boundVect ]], %[[linearIndex ]]
217
207
218
208
func.func @transfer_read_2d_to_1d_scalable (%A : memref <?x?xf32 >, %base0: index , %base1: index ) -> vector <[17 ]xf32 > {
219
209
%f7 = arith.constant 7.0 : f32
@@ -255,12 +245,13 @@ func.func @transfer_read_write_1d_non_zero_addrspace(%A : memref<?xf32, 3>, %bas
255
245
// CHECK-LABEL: func @transfer_read_write_1d_non_zero_addrspace
256
246
// CHECK-SAME: %[[BASE:[a-zA-Z0-9]*]]: index) -> vector<17xf32>
257
247
//
248
+ // CHECK: %[[c0:.*]] = arith.constant 0 : index
249
+ //
258
250
// 1. Check address space for GEP is correct.
259
251
// CHECK: %[[gep:.*]] = llvm.getelementptr {{.*}} :
260
252
// CHECK-SAME: (!llvm.ptr<3>, i64) -> !llvm.ptr<3>, f32
261
253
//
262
254
// 2. Check address space of the memref is correct.
263
- // CHECK: %[[c0:.*]] = arith.constant 0 : index
264
255
// CHECK: %[[DIM:.*]] = memref.dim %{{.*}}, %[[c0]] : memref<?xf32, 3>
265
256
//
266
257
// 3. Check address space for GEP is correct.
@@ -280,12 +271,13 @@ func.func @transfer_read_write_1d_non_zero_addrspace_scalable(%A : memref<?xf32,
280
271
// CHECK-LABEL: func @transfer_read_write_1d_non_zero_addrspace_scalable
281
272
// CHECK-SAME: %[[BASE:[a-zA-Z0-9]*]]: index) -> vector<[17]xf32>
282
273
//
274
+ // CHECK: %[[c0:.*]] = arith.constant 0 : index
275
+ //
283
276
// 1. Check address space for GEP is correct.
284
277
// CHECK: %[[gep:.*]] = llvm.getelementptr {{.*}} :
285
278
// CHECK-SAME: (!llvm.ptr<3>, i64) -> !llvm.ptr<3>, f32
286
279
//
287
280
// 2. Check address space of the memref is correct.
288
- // CHECK: %[[c0:.*]] = arith.constant 0 : index
289
281
// CHECK: %[[DIM:.*]] = memref.dim %{{.*}}, %[[c0]] : memref<?xf32, 3>
290
282
//
291
283
// 3. Check address space for GEP is correct.
@@ -330,10 +322,10 @@ func.func @transfer_read_1d_inbounds_scalable(%A : memref<?xf32>, %base: index)
330
322
331
323
// CHECK-LABEL: func @transfer_read_write_1d_mask
332
324
// CHECK: %[[mask1:.*]] = arith.constant dense<[false, false, true, false, true]>
333
- // CHECK: %[[cmpi:.*]] = arith.cmpi slt
325
+ // CHECK: %[[cmpi:.*]] = arith.cmpi sgt
334
326
// CHECK: %[[mask2:.*]] = arith.andi %[[cmpi]], %[[mask1]]
335
327
// CHECK: %[[r:.*]] = llvm.intr.masked.load %{{.*}}, %[[mask2]]
336
- // CHECK: %[[cmpi_1:.*]] = arith.cmpi slt
328
+ // CHECK: %[[cmpi_1:.*]] = arith.cmpi sgt
337
329
// CHECK: %[[mask3:.*]] = arith.andi %[[cmpi_1]], %[[mask1]]
338
330
// CHECK: llvm.intr.masked.store %[[r]], %{{.*}}, %[[mask3]]
339
331
// CHECK: return %[[r]]
0 commit comments