Index: mlir/lib/Dialect/SCF/Utils/Utils.cpp =================================================================== --- mlir/lib/Dialect/SCF/Utils/Utils.cpp +++ mlir/lib/Dialect/SCF/Utils/Utils.cpp @@ -297,7 +297,7 @@ builder.create(loc, divisor - 1); Value divisorCst = builder.create(loc, divisor); Value sum = builder.create(loc, dividend, divisorMinusOneCst); - return builder.create(loc, sum, divisorCst); + return builder.create(loc, sum, divisorCst); } // Build the IR that performs ceil division of a positive value by another @@ -311,7 +311,7 @@ Value cstOne = builder.create(loc, 1); Value divisorMinusOne = builder.create(loc, divisor, cstOne); Value sum = builder.create(loc, dividend, divisorMinusOne); - return builder.create(loc, sum, divisor); + return builder.create(loc, sum, divisor); } /// Helper to replace uses of loop carried values (iter_args) and loop Index: mlir/test/Dialect/Affine/loop-coalescing.mlir =================================================================== --- mlir/test/Dialect/Affine/loop-coalescing.mlir +++ mlir/test/Dialect/Affine/loop-coalescing.mlir @@ -91,7 +91,7 @@ // CHECK: %[[c1:.*]] = arith.constant 1 // CHECK: %[[step_minus_c1:.*]] = arith.subi %[[orig_step_i]], %[[c1]] // CHECK: %[[dividend:.*]] = arith.addi %[[diff_i]], %[[step_minus_c1]] - // CHECK: %[[numiter_i:.*]] = arith.divsi %[[dividend]], %[[orig_step_i]] + // CHECK: %[[numiter_i:.*]] = arith.divui %[[dividend]], %[[orig_step_i]] // Normalized lower bound and step for the outer scf. // CHECK: %[[lb_i:.*]] = arith.constant 0 @@ -99,7 +99,7 @@ // Number of iterations in the inner loop, the pattern is the same as above, // only capture the final result. - // CHECK: %[[numiter_j:.*]] = arith.divsi {{.*}}, %[[orig_step_j]] + // CHECK: %[[numiter_j:.*]] = arith.divui {{.*}}, %[[orig_step_j]] // New bounds of the outer scf. // CHECK: %[[range:.*]] = arith.muli %[[numiter_i]], %[[numiter_j]] @@ -137,11 +137,11 @@ // CHECK: %[[range1:.*]] = arith.subi %[[orig_ub1]], %[[orig_lb1]] // CHECK: %[[orig_step1_minus_1:.*]] = arith.subi %[[orig_step1]], %c1 // CHECK: %[[dividend1:.*]] = arith.addi %[[range1]], %[[orig_step1_minus_1]] - // CHECK: %[[numiter1:.*]] = arith.divsi %[[dividend1]], %[[orig_step1]] + // CHECK: %[[numiter1:.*]] = arith.divui %[[dividend1]], %[[orig_step1]] // CHECK: %[[range2:.*]] = arith.subi %[[orig_ub2]], %[[orig_lb2]] // CHECK: %[[orig_step2_minus_1:.*]] = arith.subi %arg5, %c1 // CHECK: %[[dividend2:.*]] = arith.addi %[[range2]], %[[orig_step2_minus_1]] - // CHECK: %[[numiter2:.*]] = arith.divsi %[[dividend2]], %[[orig_step2]] + // CHECK: %[[numiter2:.*]] = arith.divui %[[dividend2]], %[[orig_step2]] // CHECK: %[[range:.*]] = arith.muli %[[numiter1]], %[[numiter2]] : index // Check that the outer loop is updated. Index: mlir/test/Dialect/SCF/loop-unroll.mlir =================================================================== --- mlir/test/Dialect/SCF/loop-unroll.mlir +++ mlir/test/Dialect/SCF/loop-unroll.mlir @@ -25,7 +25,7 @@ // UNROLL-BY-2-DAG: %[[V1:.*]] = arith.subi %[[STEP]], %[[C1]] : index // UNROLL-BY-2-DAG: %[[V2:.*]] = arith.addi %[[V0]], %[[V1]] : index // Compute trip count in V3. -// UNROLL-BY-2-DAG: %[[V3:.*]] = arith.divsi %[[V2]], %[[STEP]] : index +// UNROLL-BY-2-DAG: %[[V3:.*]] = arith.divui %[[V2]], %[[STEP]] : index // Store unroll factor in C2. // UNROLL-BY-2-DAG: %[[C2:.*]] = arith.constant 2 : index // UNROLL-BY-2-DAG: %[[V4:.*]] = arith.remsi %[[V3]], %[[C2]] : index @@ -58,7 +58,7 @@ // UNROLL-BY-3-DAG: %[[V1:.*]] = arith.subi %[[STEP]], %[[C1]] : index // UNROLL-BY-3-DAG: %[[V2:.*]] = arith.addi %[[V0]], %[[V1]] : index // Compute trip count in V3. -// UNROLL-BY-3-DAG: %[[V3:.*]] = arith.divsi %[[V2]], %[[STEP]] : index +// UNROLL-BY-3-DAG: %[[V3:.*]] = arith.divui %[[V2]], %[[STEP]] : index // Store unroll factor in C3. // UNROLL-BY-3-DAG: %[[C3:.*]] = arith.constant 3 : index // UNROLL-BY-3-DAG: %[[V4:.*]] = arith.remsi %[[V3]], %[[C3]] : index Index: mlir/test/Transforms/parametric-tiling.mlir =================================================================== --- mlir/test/Transforms/parametric-tiling.mlir +++ mlir/test/Transforms/parametric-tiling.mlir @@ -12,11 +12,11 @@ // COMMON: %[[diff:.*]] = arith.subi %c44, %c2 // COMMON: %[[adjustment:.*]] = arith.subi %c1, %c1_{{.*}} // COMMON-NEXT: %[[diff_adj:.*]] = arith.addi %[[diff]], %[[adjustment]] - // COMMON-NEXT: %[[range:.*]] = arith.divsi %[[diff_adj]], %c1 + // COMMON-NEXT: %[[range:.*]] = arith.divui %[[diff_adj]], %c1 // Ceildiv to get the parametric tile size. // COMMON: %[[sum:.*]] = arith.addi %[[range]], %c6 - // COMMON-NEXT: %[[size:.*]] = arith.divsi %[[sum]], %c7 + // COMMON-NEXT: %[[size:.*]] = arith.divui %[[sum]], %c7 // New outer step (original is %c1). // COMMON-NEXT: %[[step:.*]] = arith.muli %c1, %[[size]] @@ -26,11 +26,11 @@ // TILE_74: %[[diff2:.*]] = arith.subi %c44, %c1 // TILE_74: %[[adjustment2:.*]] = arith.subi %c2, %c1_{{.*}} // TILE_74-NEXT: %[[diff2_adj:.*]] = arith.addi %[[diff2]], %[[adjustment2]] - // TILE_74-NEXT: %[[range2:.*]] = arith.divsi %[[diff2_adj]], %c2 + // TILE_74-NEXT: %[[range2:.*]] = arith.divui %[[diff2_adj]], %c2 // Ceildiv to get the parametric tile size for the second original scf. // TILE_74: %[[sum2:.*]] = arith.addi %[[range2]], %c3 - // TILE_74-NEXT: %[[size2:.*]] = arith.divsi %[[sum2]], %c4 + // TILE_74-NEXT: %[[size2:.*]] = arith.divui %[[sum2]], %c4 // New inner step (original is %c2). // TILE_74-NEXT: %[[step2:.*]] = arith.muli %c2, %[[size2]] @@ -76,11 +76,11 @@ // COMMON: %[[diff:.*]] = arith.subi %c44, %c2 // COMMON: %[[adjustment:.*]] = arith.subi %c1, %c1_{{.*}} // COMMON-NEXT: %[[diff_adj:.*]] = arith.addi %[[diff]], %[[adjustment]] - // COMMON-NEXT: %[[range:.*]] = arith.divsi %[[diff_adj]], %c1 + // COMMON-NEXT: %[[range:.*]] = arith.divui %[[diff_adj]], %c1 // Ceildiv to get the parametric tile size. // COMMON: %[[sum:.*]] = arith.addi %[[range]], %c6 - // COMMON-NEXT: %[[size:.*]] = arith.divsi %[[sum]], %c7 + // COMMON-NEXT: %[[size:.*]] = arith.divui %[[sum]], %c7 // New outer step (original is %c1). // COMMON-NEXT: %[[step:.*]] = arith.muli %c1, %[[size]] @@ -95,11 +95,11 @@ // where step is known to be %c2. // TILE_74: %[[diff2:.*]] = arith.subi %[[i]], %c1 // TILE_74-NEXT: %[[diff2_adj:.*]] = arith.addi %[[diff2]], %[[adjustment2]] - // TILE_74-NEXT: %[[range2:.*]] = arith.divsi %[[diff2_adj]], %c2 + // TILE_74-NEXT: %[[range2:.*]] = arith.divui %[[diff2_adj]], %c2 // Ceildiv to get the parametric tile size for the second original scf. // TILE_74: %[[sum2:.*]] = arith.addi %[[range2]], %c3 - // TILE_74-NEXT: %[[size2:.*]] = arith.divsi %[[sum2]], %c4 + // TILE_74-NEXT: %[[size2:.*]] = arith.divui %[[sum2]], %c4 // New inner step (original is %c2). // TILE_74-NEXT: %[[step2:.*]] = arith.muli %c2, %[[size2]]