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