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