Skip to content

Commit 92cf042

Browse files
committed
Simplying, formatting and adding doc.
1 parent 488b3b6 commit 92cf042

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

mlir/include/mlir/Dialect/Arith/Utils/Utils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ Value createScalarOrSplatConstant(OpBuilder &builder, Location loc, Type type,
9393
int64_t value);
9494
Value createScalarOrSplatConstant(OpBuilder &builder, Location loc, Type type,
9595
const APFloat &value);
96+
97+
/// Create a constant of type `type` at location `loc` whose value is `value`.
98+
/// This works for integer type or the index type only.
9699
Value createIntOrIndexConstant(OpBuilder &builder, Location loc, Type type,
97100
int64_t value);
98101

mlir/lib/Dialect/Arith/Utils/Utils.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,7 @@ Value mlir::createIntOrIndexConstant(OpBuilder &b, Location loc, Type type,
306306
int64_t value) {
307307
assert(type.isIntOrIndex() &&
308308
"unexpected type other than integers and index");
309-
if (type.isIndex())
310-
return b.create<arith::ConstantIndexOp>(loc, value);
311-
else
312-
return b.create<arith::ConstantOp>(loc, b.getIntegerAttr(type, value));
309+
return b.create<arith::ConstantOp>(loc, b.getIntegerAttr(type, value));
313310
}
314311

315312
Type mlir::getType(OpFoldResult ofr) {

mlir/lib/Dialect/SCF/Utils/Utils.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,8 @@ LogicalResult mlir::loopUnrollByFactor(
391391
generateEpilogueLoop = upperBoundUnrolledCst < ubCst;
392392
if (generateEpilogueLoop)
393393
upperBoundUnrolled = createIntOrIndexConstant(
394-
boundsBuilder, loc, forOp.getUpperBound().getType(), upperBoundUnrolledCst);
394+
boundsBuilder, loc, forOp.getUpperBound().getType(),
395+
upperBoundUnrolledCst);
395396
else
396397
upperBoundUnrolled = forOp.getUpperBound();
397398

0 commit comments

Comments
 (0)