brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · f63aa88 Raw
57 lines · plain
1// RUN: mlir-opt %s -convert-vector-to-scf -convert-scf-to-cf -convert-vector-to-llvm -convert-func-to-llvm -convert-arith-to-llvm -convert-cf-to-llvm -reconcile-unrealized-casts |  \2// RUN: mlir-runner -e entry_point_with_all_constants -entry-point-result=void \3// RUN:   -shared-libs=%mlir_c_runner_utils4 5module {6  func.func @function_to_run(%a: vector<8xf32>, %b: vector<8xf32>)  {7    // CHECK: ( 8, 10, 12, 14, 16, 18, 20, 22 )8    %r0 = llvm.inline_asm asm_dialect = intel9        "vaddps $0, $1, $2", "=x,x,x" %a, %b:10      (vector<8xf32>, vector<8xf32>) -> vector<8xf32>11    vector.print %r0: vector<8xf32>12 13    // vblendps implemented with inline_asm.14    // CHECK: ( 0, 1, 10, 11, 4, 5, 14, 15 )15    %r1 = llvm.inline_asm asm_dialect = intel16        "vblendps $0, $1, $2, 0xCC", "=x,x,x" %a, %b:17      (vector<8xf32>, vector<8xf32>) -> vector<8xf32>18    vector.print %r1: vector<8xf32>19 20    // vblendps 0xCC via vector.shuffle (emulates clang intrinsics impl)21    // CHECK: ( 0, 1, 10, 11, 4, 5, 14, 15 )22    %r2 = vector.shuffle %a, %b[0, 1, 10, 11, 4, 5, 14, 15]23      : vector<8xf32>, vector<8xf32>24    vector.print %r2: vector<8xf32>25 26    // vblendps 0x33 implemented with inline_asm.27    // CHECK: ( 8, 9, 2, 3, 12, 13, 6, 7 )28    %r3 = llvm.inline_asm asm_dialect = intel29        "vblendps $0, $1, $2, 0x33", "=x,x,x" %a, %b:30      (vector<8xf32>, vector<8xf32>) -> vector<8xf32>31    vector.print %r3: vector<8xf32>32 33    // vblendps 0x33 via vector.shuffle (emulates clang intrinsics impl)34    // CHECK: ( 8, 9, 2, 3, 12, 13, 6, 7 )35    %r4 = vector.shuffle %a, %b[8, 9, 2, 3, 12, 13, 6, 7]36      : vector<8xf32>, vector<8xf32>37    vector.print %r4: vector<8xf32>38 39    return40  }41 42  // Solely exists to prevent inlining and get the expected assembly.43  func.func @entry_point(%a: vector<8xf32>, %b: vector<8xf32>)  {44    func.call @function_to_run(%a, %b) : (vector<8xf32>, vector<8xf32>) -> ()45    return46  }47 48  func.func @entry_point_with_all_constants()  {49    %a = llvm.mlir.constant(dense<[0.0, 1.0,  2.0,  3.0,  4.0,  5.0,  6.0,  7.0]>50      : vector<8xf32>) : vector<8xf32>51    %b = llvm.mlir.constant(dense<[8.0, 9.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0]>52      : vector<8xf32>) : vector<8xf32>53    func.call @function_to_run(%a, %b) : (vector<8xf32>, vector<8xf32>) -> ()54    return55  }56}57