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  %c0 = constant 0 : index
8  %c1 = constant 1 : index
9  %c2 = constant 2 : index
10  %c3 = constant 3 : index
11  %c6 = constant 6 : index
12
13  //
14  // 1-D.
15  //
16
17  %1 = vector.create_mask %c2 : vector<5xi1>
18  vector.print %1 : vector<5xi1>
19  // CHECK: ( 1, 1, 0, 0, 0 )
20
21  scf.for %i = %c0 to %c6 step %c1 {
22    %2 = vector.create_mask %i : vector<5xi1>
23    vector.print %2 : vector<5xi1>
24  }
25  // CHECK: ( 0, 0, 0, 0, 0 )
26  // CHECK: ( 1, 0, 0, 0, 0 )
27  // CHECK: ( 1, 1, 0, 0, 0 )
28  // CHECK: ( 1, 1, 1, 0, 0 )
29  // CHECK: ( 1, 1, 1, 1, 0 )
30  // CHECK: ( 1, 1, 1, 1, 1 )
31
32  //
33  // 2-D.
34  //
35
36  %3 = vector.create_mask %c2, %c3 : vector<5x5xi1>
37  vector.print %3 : vector<5x5xi1>
38  // CHECK: ( ( 1, 1, 1, 0, 0 ), ( 1, 1, 1, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
39
40  %4 = vector.create_mask %c3, %c2 : vector<5x5xi1>
41  vector.print %4 : vector<5x5xi1>
42  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
43
44  scf.for %i = %c0 to %c6 step %c1 {
45    %5 = vector.create_mask %c2, %i : vector<5x5xi1>
46    vector.print %5 : vector<5x5xi1>
47  }
48  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
49  // CHECK: ( ( 1, 0, 0, 0, 0 ), ( 1, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
50  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
51  // CHECK: ( ( 1, 1, 1, 0, 0 ), ( 1, 1, 1, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
52  // CHECK: ( ( 1, 1, 1, 1, 0 ), ( 1, 1, 1, 1, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
53  // CHECK: ( ( 1, 1, 1, 1, 1 ), ( 1, 1, 1, 1, 1 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
54
55  scf.for %i = %c0 to %c6 step %c1 {
56    %6 = vector.create_mask %i, %c2 : vector<5x5xi1>
57    vector.print %6 : vector<5x5xi1>
58  }
59  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
60  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
61  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
62  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
63  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
64  // CHECK: ( ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ), ( 1, 1, 0, 0, 0 ) )
65
66  scf.for %i = %c0 to %c6 step %c1 {
67    scf.for %j = %c0 to %c6 step %c1 {
68      %7 = vector.create_mask %i, %j : vector<5x5xi1>
69      vector.print %7 : vector<5x5xi1>
70    }
71  }
72  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
73  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
74  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
75  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
76  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ) )
77  // CHECK: ( ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0, 0, 0, 0, 0 ), ( 0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