1// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func.func(scf-parallel-loop-collapsing{collapsed-indices-0=0,3 collapsed-indices-1=1,4 collapsed-indices-2=2}, canonicalize)' | FileCheck %s
2
3// CHECK-LABEL: func @parallel_many_dims() {
4func.func @parallel_many_dims() {
5  %c0 = arith.constant 0 : index
6  %c1 = arith.constant 1 : index
7  %c2 = arith.constant 2 : index
8  %c3 = arith.constant 3 : index
9  %c4 = arith.constant 4 : index
10  %c5 = arith.constant 5 : index
11  %c6 = arith.constant 6 : index
12  %c7 = arith.constant 7 : index
13  %c8 = arith.constant 8 : index
14  %c9 = arith.constant 9 : index
15  %c10 = arith.constant 10 : index
16  %c11 = arith.constant 11 : index
17  %c12 = arith.constant 12 : index
18  %c13 = arith.constant 13 : index
19  %c14 = arith.constant 14 : index
20  %c15 = arith.constant 15 : index
21  %c26 = arith.constant 26 : index
22
23  scf.parallel (%i0, %i1, %i2, %i3, %i4) = (%c0, %c3, %c6, %c9, %c12)
24    to (%c2, %c5, %c8, %c26, %c14) step (%c1, %c4, %c7, %c10, %c13) {
25    %result = "magic.op"(%i0, %i1, %i2, %i3, %i4)
26        : (index, index, index, index, index) -> index
27  }
28  return
29}
30
31// CHECK-DAG: [[C12:%.*]] = arith.constant 12 : index
32// CHECK-DAG: [[C10:%.*]] = arith.constant 10 : index
33// CHECK-DAG: [[C9:%.*]] = arith.constant 9 : index
34// CHECK-DAG: [[C6:%.*]] = arith.constant 6 : index
35// CHECK-DAG: [[C4:%.*]] = arith.constant 4 : index
36// CHECK-DAG: [[C3:%.*]] = arith.constant 3 : index
37// CHECK-DAG: [[C2:%.*]] = arith.constant 2 : index
38// CHECK-DAG: [[C1:%.*]] = arith.constant 1 : index
39// CHECK-DAG: [[C0:%.*]] = arith.constant 0 : index
40// CHECK: scf.parallel ([[NEW_I0:%.*]]) = ([[C0]]) to ([[C4]]) step ([[C1]]) {
41// CHECK:   [[V0:%.*]] = arith.remsi [[NEW_I0]], [[C2]] : index
42// CHECK:   [[I0:%.*]] = arith.divsi [[NEW_I0]], [[C2]] : index
43// CHECK:   [[V2:%.*]] = arith.muli [[V0]], [[C10]] : index
44// CHECK:   [[I3:%.*]] = arith.addi [[V2]], [[C9]] : index
45// CHECK:   "magic.op"([[I0]], [[C3]], [[C6]], [[I3]], [[C12]]) : (index, index, index, index, index) -> index
46// CHECK:   scf.yield
47