brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.7 KiB · 1683fa5 Raw
105 lines · plain
1// RUN: mlir-opt %s -test-lower-to-llvm  | \2// RUN: mlir-runner -e entry -entry-point-result=void \3// RUN:   -shared-libs=%mlir_c_runner_utils | \4// RUN: FileCheck %s5 6func.func @compress16(%base: memref<?xf32>,7                 %mask: vector<16xi1>, %value: vector<16xf32>) {8  %c0 = arith.constant 0: index9  vector.compressstore %base[%c0], %mask, %value10    : memref<?xf32>, vector<16xi1>, vector<16xf32>11  return12}13 14func.func @compress16_at8(%base: memref<?xf32>,15                     %mask: vector<16xi1>, %value: vector<16xf32>) {16  %c8 = arith.constant 8: index17  vector.compressstore %base[%c8], %mask, %value18    : memref<?xf32>, vector<16xi1>, vector<16xf32>19  return20}21 22func.func @printmem16(%A: memref<?xf32>) {23  %c0 = arith.constant 0: index24  %c1 = arith.constant 1: index25  %c16 = arith.constant 16: index26  %z = arith.constant 0.0: f3227  %m = vector.broadcast %z : f32 to vector<16xf32>28  %mem = scf.for %i = %c0 to %c16 step %c129    iter_args(%m_iter = %m) -> (vector<16xf32>) {30    %c = memref.load %A[%i] : memref<?xf32>31    %m_new = vector.insert %c, %m_iter[%i] : f32 into vector<16xf32>32    scf.yield %m_new : vector<16xf32>33  }34  vector.print %mem : vector<16xf32>35  return36}37 38func.func @entry() {39  // Set up memory.40  %c0 = arith.constant 0: index41  %c1 = arith.constant 1: index42  %c16 = arith.constant 16: index43  %A = memref.alloc(%c16) : memref<?xf32>44  %z = arith.constant 0.0: f3245  %v = vector.broadcast %z : f32 to vector<16xf32>46  %value = scf.for %i = %c0 to %c16 step %c147    iter_args(%v_iter = %v) -> (vector<16xf32>) {48    memref.store %z, %A[%i] : memref<?xf32>49    %i32 = arith.index_cast %i : index to i3250    %fi = arith.sitofp %i32 : i32 to f3251    %v_new = vector.insert %fi, %v_iter[%i] : f32 into vector<16xf32>52    scf.yield %v_new : vector<16xf32>53  }54 55  // Set up masks.56  %f = arith.constant 0: i157  %t = arith.constant 1: i158  %none = vector.constant_mask [0] : vector<16xi1>59  %all = vector.constant_mask [16] : vector<16xi1>60  %some1 = vector.constant_mask [4] : vector<16xi1>61  %0 = vector.insert %f, %some1[0] : i1 into vector<16xi1>62  %1 = vector.insert %t, %0[7] : i1 into vector<16xi1>63  %2 = vector.insert %t, %1[11] : i1 into vector<16xi1>64  %3 = vector.insert %t, %2[13] : i1 into vector<16xi1>65  %some2 = vector.insert %t, %3[15] : i1 into vector<16xi1>66  %some3 = vector.insert %f, %some2[2] : i1 into vector<16xi1>67 68  //69  // Expanding load tests.70  //71 72  call @compress16(%A, %none, %value)73    : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()74  call @printmem16(%A) : (memref<?xf32>) -> ()75  // CHECK: ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 )76 77  call @compress16(%A, %all, %value)78    : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()79  call @printmem16(%A) : (memref<?xf32>) -> ()80  // CHECK-NEXT: ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 )81 82  call @compress16(%A, %some3, %value)83    : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()84  call @printmem16(%A) : (memref<?xf32>) -> ()85  // CHECK-NEXT: ( 1, 3, 7, 11, 13, 15, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 )86 87  call @compress16(%A, %some2, %value)88    : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()89  call @printmem16(%A) : (memref<?xf32>) -> ()90  // CHECK-NEXT: ( 1, 2, 3, 7, 11, 13, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15 )91 92  call @compress16(%A, %some1, %value)93    : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()94  call @printmem16(%A) : (memref<?xf32>) -> ()95  // CHECK-NEXT: ( 0, 1, 2, 3, 11, 13, 15, 7, 8, 9, 10, 11, 12, 13, 14, 15 )96 97  call @compress16_at8(%A, %some1, %value)98    : (memref<?xf32>, vector<16xi1>, vector<16xf32>) -> ()99  call @printmem16(%A) : (memref<?xf32>) -> ()100  // CHECK-NEXT: ( 0, 1, 2, 3, 11, 13, 15, 7, 0, 1, 2, 3, 12, 13, 14, 15 )101 102  memref.dealloc %A : memref<?xf32>103  return104}105