30 lines · plain
1// RUN: mlir-opt -allow-unregistered-dialect -pass-pipeline='builtin.module(func.func(test-scf-parallel-loop-collapsing{collapsed-indices-0=0,1}, canonicalize))' --mlir-print-local-scope %s | FileCheck %s2 3func.func @collapse_to_single() {4 %c0 = arith.constant 3 : index5 %c1 = arith.constant 7 : index6 %c2 = arith.constant 11 : index7 %c3 = arith.constant 29 : index8 %c4 = arith.constant 3 : index9 %c5 = arith.constant 4 : index10 scf.parallel (%i0, %i1) = (%c0, %c1) to (%c2, %c3) step (%c4, %c5) {11 %result = "magic.op"(%i0, %i1): (index, index) -> index12 }13 return14}15 16// CHECK: func @collapse_to_single() {17// CHECK-DAG: %[[C6:.*]] = arith.constant 6 : index18// CHECK-DAG: %[[C0:.*]] = arith.constant 0 : index19// CHECK-DAG: %[[C1:.*]] = arith.constant 1 : index20// CHECK-DAG: %[[C18:.*]] = arith.constant 18 : index21// CHECK: scf.parallel (%[[NEW_I:.*]]) = (%[[C0]]) to (%[[C18]]) step (%[[C1]]) {22// CHECK: %[[I0_COUNT:.*]] = arith.remsi %[[NEW_I]], %[[C6]] : index23// CHECK: %[[I1_COUNT:.*]] = arith.divsi %[[NEW_I]], %[[C6]] : index24// CHECK: %[[I1:.*]] = affine.apply affine_map<(d0) -> (d0 * 4 + 7)>(%[[I0_COUNT]])25// CHECK: %[[I0:.*]] = affine.apply affine_map<(d0) -> (d0 * 3 + 3)>(%[[I1_COUNT]])26// CHECK: "magic.op"(%[[I0]], %[[I1]]) : (index, index) -> index27// CHECK: scf.reduce28// CHECK-NEXT: }29// CHECK-NEXT: return30