@@ -267,10 +267,10 @@ static Value ceilDivPositive(OpBuilder &builder, Location loc, Value dividend,
267
267
assert (dividend.getType ().isIntOrIndex () &&
268
268
" expected integer or index-typed value" );
269
269
270
- Value divisorMinusOneCst =
271
- createIntOrIndexConstant (builder, loc, dividend.getType (), divisor - 1 );
272
- Value divisorCst =
273
- createIntOrIndexConstant (builder, loc, dividend.getType (), divisor);
270
+ Value divisorMinusOneCst = builder. create <arith::ConstantOp>(
271
+ loc, builder. getIntegerAttr ( dividend.getType (), divisor - 1 ) );
272
+ Value divisorCst = builder. create <arith::ConstantOp>(
273
+ loc, builder. getIntegerAttr ( dividend.getType (), divisor) );
274
274
Value sum = builder.create <arith::AddIOp>(loc, dividend, divisorMinusOneCst);
275
275
return builder.create <arith::DivUIOp>(loc, sum, divisorCst);
276
276
}
@@ -283,7 +283,8 @@ static Value ceilDivPositive(OpBuilder &builder, Location loc, Value dividend,
283
283
Value divisor) {
284
284
assert (dividend.getType ().isIntOrIndex () &&
285
285
" expected integer or index-typed value" );
286
- Value cstOne = createIntOrIndexConstant (builder, loc, dividend.getType (), 1 );
286
+ Value cstOne = builder.create <arith::ConstantOp>(
287
+ loc, builder.getOneAttr (dividend.getType ()));
287
288
Value divisorMinusOne = builder.create <arith::SubIOp>(loc, divisor, cstOne);
288
289
Value sum = builder.create <arith::AddIOp>(loc, dividend, divisorMinusOne);
289
290
return builder.create <arith::DivUIOp>(loc, sum, divisor);
@@ -390,18 +391,18 @@ LogicalResult mlir::loopUnrollByFactor(
390
391
// Create constant for 'upperBoundUnrolled' and set epilogue loop flag.
391
392
generateEpilogueLoop = upperBoundUnrolledCst < ubCst;
392
393
if (generateEpilogueLoop)
393
- upperBoundUnrolled = createIntOrIndexConstant (
394
- boundsBuilder, loc, forOp.getUpperBound ().getType (),
395
- upperBoundUnrolledCst);
394
+ upperBoundUnrolled = boundsBuilder. create <arith::ConstantOp> (
395
+ loc, boundsBuilder. getIntegerAttr ( forOp.getUpperBound ().getType (),
396
+ upperBoundUnrolledCst) );
396
397
else
397
398
upperBoundUnrolled = forOp.getUpperBound ();
398
399
399
400
// Create constant for 'stepUnrolled'.
400
- stepUnrolled =
401
- stepCst == stepUnrolledCst
402
- ? step
403
- : createIntOrIndexConstant (boundsBuilder, loc, step. getType (),
404
- stepUnrolledCst);
401
+ stepUnrolled = stepCst == stepUnrolledCst
402
+ ? step
403
+ : boundsBuilder. create <arith::ConstantOp>(
404
+ loc, boundsBuilder. getIntegerAttr (
405
+ step. getType (), stepUnrolledCst) );
405
406
} else {
406
407
// Dynamic loop bounds computation.
407
408
// TODO: Add dynamic asserts for negative lb/ub/step, or
@@ -411,8 +412,8 @@ LogicalResult mlir::loopUnrollByFactor(
411
412
Value diff =
412
413
boundsBuilder.create <arith::SubIOp>(loc, upperBound, lowerBound);
413
414
Value tripCount = ceilDivPositive (boundsBuilder, loc, diff, step);
414
- Value unrollFactorCst = createIntOrIndexConstant (
415
- boundsBuilder, loc, tripCount.getType (), unrollFactor);
415
+ Value unrollFactorCst = boundsBuilder. create <arith::ConstantOp> (
416
+ loc, boundsBuilder. getIntegerAttr ( tripCount.getType (), unrollFactor) );
416
417
Value tripCountRem =
417
418
boundsBuilder.create <arith::RemSIOp>(loc, tripCount, unrollFactorCst);
418
419
// Compute tripCountEvenMultiple = tripCount - (tripCount % unrollFactor)
@@ -459,7 +460,9 @@ LogicalResult mlir::loopUnrollByFactor(
459
460
[&](unsigned i, Value iv, OpBuilder b) {
460
461
// iv' = iv + step * i;
461
462
auto stride = b.create <arith::MulIOp>(
462
- loc, step, createIntOrIndexConstant (b, loc, iv.getType (), i));
463
+ loc, step,
464
+ b.create <arith::ConstantOp>(loc,
465
+ b.getIntegerAttr (iv.getType (), i)));
463
466
return b.create <arith::AddIOp>(loc, iv, stride);
464
467
},
465
468
annotateFn, iterArgs, yieldedValues);
0 commit comments