1// RUN: mlir-opt -allow-unregistered-dialect %s -pass-pipeline='func(parallel-loop-collapsing{collapsed-indices-0=0,1}, canonicalize)' | FileCheck %s 2 3func @collapse_to_single() { 4 %c0 = constant 3 : index 5 %c1 = constant 7 : index 6 %c2 = constant 11 : index 7 %c3 = constant 29 : index 8 %c4 = constant 3 : index 9 %c5 = constant 4 : index 10 scf.parallel (%i0, %i1) = (%c0, %c1) to (%c2, %c3) step (%c4, %c5) { 11 %result = "magic.op"(%i0, %i1): (index, index) -> index 12 } 13 return 14} 15 16// CHECK-LABEL: func @collapse_to_single() { 17// CHECK: [[C7:%.*]] = constant 7 : index 18// CHECK: [[C4:%.*]] = constant 4 : index 19// CHECK: [[C18:%.*]] = constant 18 : index 20// CHECK: [[C3:%.*]] = constant 3 : index 21// CHECK: [[C0:%.*]] = constant 0 : index 22// CHECK: [[C1:%.*]] = constant 1 : index 23// CHECK: scf.parallel ([[NEW_I:%.*]]) = ([[C0]]) to ([[C18]]) step ([[C1]]) { 24// CHECK: [[I0_COUNT:%.*]] = remi_signed [[NEW_I]], [[C3]] : index 25// CHECK: [[I1_COUNT:%.*]] = divi_signed [[NEW_I]], [[C3]] : index 26// CHECK: [[V0:%.*]] = muli [[I1_COUNT]], [[C4]] : index 27// CHECK: [[I1:%.*]] = addi [[V0]], [[C7]] : index 28// CHECK: [[V1:%.*]] = muli [[I0_COUNT]], [[C3]] : index 29// CHECK: [[I0:%.*]] = addi [[V1]], [[C3]] : index 30// CHECK: "magic.op"([[I0]], [[I1]]) : (index, index) -> index 31// CHECK: scf.yield 32// CHECK-NEXT: } 33// CHECK-NEXT: return 34