Skip to content

Commit d87cb14

Browse files
committed
[mlir][Vector] Add integration test for vector.maskedload narrow type emulation pattern
1 parent 51348ae commit d87cb14

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

mlir/test/Integration/Dialect/Vector/CPU/test-rewrite-narrow-types.mlir

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,13 @@ func.func @fext(%a: vector<5xi8>) {
164164
return
165165
}
166166

167+
func.func @fcst_maskedload(%A: memref<?xi4>, %passthru: vector<6xi4>) -> vector<6xi4> {
168+
%c0 = arith.constant 0: index
169+
%mask = vector.constant_mask [3] : vector<6xi1>
170+
%1 = vector.maskedload %A[%c0], %mask, %passthru :
171+
memref<?xi4>, vector<6xi1>, vector<6xi4> into vector<6xi4>
172+
return %1 : vector<6xi4>
173+
}
167174

168175
func.func @entry() {
169176
%v = arith.constant dense<[
@@ -187,6 +194,21 @@ func.func @entry() {
187194
]> : vector<5xi8>
188195
func.call @fext(%v4) : (vector<5xi8>) -> ()
189196

197+
// Set up memory.
198+
%c0 = arith.constant 0: index
199+
%c1 = arith.constant 1: index
200+
%c6 = arith.constant 6: index
201+
%A = memref.alloc(%c6) : memref<?xi4>
202+
scf.for %i = %c0 to %c6 step %c1 {
203+
%i4 = arith.index_cast %i : index to i4
204+
memref.store %i4, %A[%i] : memref<?xi4>
205+
}
206+
%passthru = arith.constant dense<[7, 8, 9, 10, 11, 12]> : vector<6xi4>
207+
%load = call @fcst_maskedload(%A, %passthru) : (memref<?xi4>, vector<6xi4>) -> (vector<6xi4>)
208+
vector.print %load : vector<6xi4>
209+
// CHECK: ( 1, 2, 3, -6, -5, -4 )
210+
memref.dealloc %A : memref<?xi4>
211+
190212
return
191213
}
192214

0 commit comments

Comments
 (0)