xref: /llvm-project/mlir/test/Integration/Dialect/Vector/CPU/X86Vector/inline-asm-vector-avx512.mlir (revision 435114f9fe2139bec770e5a95799f4eab20639e7)
1// RUN: mlir-opt %s -convert-linalg-to-loops -convert-vector-to-scf='full-unroll=true' -lower-affine -convert-scf-to-cf -convert-vector-to-llvm -finalize-memref-to-llvm  -convert-func-to-llvm='use-bare-ptr-memref-call-conv=1' -convert-arith-to-llvm -reconcile-unrealized-casts |\
2// RUN: mlir-translate --mlir-to-llvmir |\
3// RUN: %lli --entry-function=entry --mattr="avx512f" --dlopen=%mlir_c_runner_utils |\
4// RUN: FileCheck %s
5
6module {
7
8  // an array of 16 i32 of values [0..15]
9  llvm.mlir.global private @const16(
10    dense<[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15]> : tensor<16 x i32>)
11      : !llvm.array<16 x i32>
12
13  llvm.func @entry() -> i32 {
14    %c0 = llvm.mlir.constant(0 : index) : i64
15
16    %1 = llvm.mlir.addressof @const16 : !llvm.ptr
17    %ptr = llvm.getelementptr %1[%c0, %c0]
18      : (!llvm.ptr, i64, i64) -> !llvm.ptr, !llvm.array<16 x i32>
19
20    // operand_attrs of *m operands need to be piped through to LLVM for
21    // verification to pass.
22    %v = llvm.inline_asm
23        asm_dialect = intel
24        operand_attrs = [{ elementtype = vector<16xi32> }]
25        "vmovdqu32 $0, $1", "=x,*m" %ptr
26      : (!llvm.ptr) -> vector<16xi32>
27
28    // CHECK: 0
29    %v0 = vector.extract %v[0]: i32 from vector<16xi32>
30    vector.print %v0 : i32
31
32    // CHECK: 9
33    %v9 = vector.extract %v[9]: i32 from vector<16xi32>
34    vector.print %v9 : i32
35
36    %i0 = arith.constant 0 : i32
37    llvm.return %i0 : i32
38  }
39}
40
41