xref: /llvm-project/mlir/test/Integration/Dialect/Vector/CPU/index-vectors.mlir (revision eb206e9ea84eff0a0596fed2de8316d924f946d1)
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 %s
5
6func.func @entry() {
7  %c0 = arith.constant dense<[0, 1, 2, 3]>: vector<4xindex>
8  %c1 = arith.constant dense<[0, 1]>: vector<2xindex>
9  %c2 = arith.constant 2 : index
10
11  %v1 = vector.broadcast %c0 : vector<4xindex> to vector<2x4xindex>
12  %v2 = vector.broadcast %c1 : vector<2xindex> to vector<4x2xindex>
13  %v3 = vector.transpose %v2, [1, 0] : vector<4x2xindex> to vector<2x4xindex>
14  %v4 = vector.broadcast %c2 : index to vector<2x4xindex>
15
16  %v5 = arith.addi %v1, %v3 : vector<2x4xindex>
17
18  vector.print %v1 : vector<2x4xindex>
19  vector.print %v3 : vector<2x4xindex>
20  vector.print %v4 : vector<2x4xindex>
21  vector.print %v5 : vector<2x4xindex>
22
23  //
24  // created index vectors:
25  //
26  // CHECK: ( ( 0, 1, 2, 3 ), ( 0, 1, 2, 3 ) )
27  // CHECK: ( ( 0, 0, 0, 0 ), ( 1, 1, 1, 1 ) )
28  // CHECK: ( ( 2, 2, 2, 2 ), ( 2, 2, 2, 2 ) )
29  // CHECK: ( ( 0, 1, 2, 3 ), ( 1, 2, 3, 4 ) )
30
31  return
32}
33