1 // RUN: mlir-opt %s -convert-scf-to-std -convert-vector-to-llvm -convert-memref-to-llvm -convert-std-to-llvm -reconcile-unrealized-casts | \
2 // RUN: mlir-cpu-runner -e entry -entry-point-result=void \
3 // RUN: -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext | \
6 func @compress16(%base: memref<?xf32>,
7 %mask: vector<16xi1>, %value: vector<16xf32>) {
8 %c0 = arith.constant 0: index
9 vector.compressstore %base[%c0], %mask, %value
10 : memref<?xf32>, vector<16xi1>, vector<16xf32>
14 func @compress16_at8(%base: memref<?xf32>,
15 %mask: vector<16xi1>, %value: vector<16xf32>) {
16 %c8 = arith.constant 8: index
17 vector.compressstore %base[%c8], %mask, %value
18 : memref<?xf32>, vector<16xi1>, vector<16xf32>
22 func @printmem16(%A: memref<?xf32>) {
23 %c0 = arith.constant 0: index
24 %c1 = arith.constant 1: index
25 %c16 = arith.constant 16: index
26 %z = arith.constant 0.0: f32
27 %m = vector.broadcast %z : f32 to vector<16xf32>
28 %mem = scf.for %i = %c0 to %c16 step %c1
29 iter_args(%m_iter = %m) -> (vector<16xf32>) {
30 %c = memref.load %A[%i] : memref<?xf32>
31 %i32 = arith.index_cast %i : index to i32
32 %m_new = vector.insertelement %c, %m_iter[%i32 : i32] : vector<16xf32>
33 scf.yield %m_new : vector<16xf32>
35 vector.print %mem : vector<16xf32>
41 %c0 = arith.constant 0: index
42 %c1 = arith.constant 1: index
43 %c16 = arith.constant 16: index
44 %A = memref.alloc(%c16) : memref<?xf32>
45 %z = arith.constant 0.0: f32
46 %v = vector.broadcast %z : f32 to vector<16xf32>
47 %value = scf.for %i = %c0 to %c16 step %c1
48 iter_args(%v_iter = %v) -> (vector<16xf32>) {
49 memref.store %z, %A[%i] : memref<?xf32>
50 %i32 = arith.index_cast %i : index to i32
51 %fi = arith.sitofp %i32 : i32 to f32
52 %v_new = vector.insertelement %fi, %v_iter[%i32 : i32] : vector<16xf32>
53 scf.yield %v_new : vector<16xf32>
57 %f = arith.constant 0: i1
58 %t = arith.constant 1: i1
59 %none = vector.constant_mask [0] : vector<16xi1>
60 %all = vector.constant_mask [16] : vector<16xi1>
61 %some1 = vector.constant_mask [4] : vector<16xi1>
62 %0 = vector.insert %f, %some1[0] : i1 into vector<16xi1>
63 %1 = vector.insert %t, %0[7] : i1 into vector<16xi1>
64 %2 = vector.insert %t, %1[11] : i1 into vector<16xi1>
65 %3 = vector.insert %t, %2[13] : i1 into vector<16xi1>
66 %some2 = vector.insert %t, %3[15] : i1 into vector<16xi1>
67 %some3 = vector.insert %f, %some2[2] : i1 into vector<16xi1>
70 // Expanding load tests.
73 call @compress16(%A, %none, %value)
74 : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()
75 call @printmem16(%A) : (memref<?xf32>) -> ()
76 // CHECK: ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )
78 call @compress16(%A, %all, %value)
79 : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()
80 call @printmem16(%A) : (memref<?xf32>) -> ()
81 // CHECK-NEXT: ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 )
83 call @compress16(%A, %some3, %value)
84 : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()
85 call @printmem16(%A) : (memref<?xf32>) -> ()
86 // CHECK-NEXT: ( 1, 3, 7, 11, 13, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 )
88 call @compress16(%A, %some2, %value)
89 : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()
90 call @printmem16(%A) : (memref<?xf32>) -> ()
91 // CHECK-NEXT: ( 1, 2, 3, 7, 11, 13, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15 )
93 call @compress16(%A, %some1, %value)
94 : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()
95 call @printmem16(%A) : (memref<?xf32>) -> ()
96 // CHECK-NEXT: ( 0, 1, 2, 3, 11, 13, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15 )
98 call @compress16_at8(%A, %some1, %value)
99 : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()
100 call @printmem16(%A) : (memref<?xf32>) -> ()
101 // CHECK-NEXT: ( 0, 1, 2, 3, 11, 13, 15, 7, 0, 1, 2, 3, 12, 13, 14, 15 )
103 memref.dealloc %A : memref<?xf32>