1// RUN: mlir-opt %s -convert-scf-to-std -convert-vector-to-llvm -convert-std-to-llvm | \
2// RUN: mlir-cpu-runner -e entry -entry-point-result=void  \
3// RUN:   -shared-libs=%mlir_integration_test_dir/libmlir_c_runner_utils%shlibext | \
4// RUN: FileCheck %s
5
6func @entry() {
7  %f1 = constant 1.0: f32
8  %f2 = constant 2.0: f32
9  %f3 = constant 3.0: f32
10  %f4 = constant 4.0: f32
11  %f5 = constant 5.0: f32
12  %f6 = constant 6.0: f32
13
14  // Construct test vector.
15  %0 = vector.broadcast %f1 : f32 to vector<3x2xf32>
16  %1 = vector.insert %f2, %0[0, 1] : f32 into vector<3x2xf32>
17  %2 = vector.insert %f3, %1[1, 0] : f32 into vector<3x2xf32>
18  %3 = vector.insert %f4, %2[1, 1] : f32 into vector<3x2xf32>
19  %4 = vector.insert %f5, %3[2, 0] : f32 into vector<3x2xf32>
20  %x = vector.insert %f6, %4[2, 1] : f32 into vector<3x2xf32>
21  vector.print %x : vector<3x2xf32>
22  // CHECK:  ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) )
23
24  // Reshapes.
25  %a = vector.shape_cast %x : vector<3x2xf32> to vector<3x2xf32>
26  %b = vector.shape_cast %x : vector<3x2xf32> to vector<2x3xf32>
27  %c = vector.shape_cast %x : vector<3x2xf32> to vector<6xf32>
28  %d = vector.shape_cast %c : vector<6xf32> to vector<2x3xf32>
29  %e = vector.shape_cast %c : vector<6xf32> to vector<3x2xf32>
30
31  // Reshaped vectors:
32  // CHECK:  ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) )
33  // CHECK: ( ( 1, 2, 3 ), ( 4, 5, 6 ) )
34  // CHECK: ( 1, 2, 3, 4, 5, 6 )
35  // CHECK: ( ( 1, 2, 3 ), ( 4, 5, 6 ) )
36  // CHECK: ( ( 1, 2 ), ( 3, 4 ), ( 5, 6 ) )
37  vector.print %a : vector<3x2xf32>
38  vector.print %b : vector<2x3xf32>
39  vector.print %c : vector<6xf32>
40  vector.print %d : vector<2x3xf32>
41  vector.print %e : vector<3x2xf32>
42
43  return
44}
45