[Mlir-commits] [mlir] [mlir][scf] Allow unrolling loops with integer-typed IV. (PR #106164)

Hongtao Yu llvmlistbot at llvm.org
Mon Aug 26 17:53:47 PDT 2024


================
@@ -302,6 +302,16 @@ Value mlir::createScalarOrSplatConstant(OpBuilder &builder, Location loc,
   return builder.createOrFold<arith::ConstantOp>(loc, type, splat);
 }
 
+Value mlir::createIntOrIndexConstant(OpBuilder &b, Location loc, Type type,
+                                     int64_t value) {
+  assert(type.isIntOrIndex() &&
+         "unexpected type other than integers and index");
+  if (type.isIndex())
+    return b.create<arith::ConstantIndexOp>(loc, value);
+  else
+    return b.create<arith::ConstantOp>(loc, b.getIntegerAttr(type, value));
----------------
htyu wrote:

Good point. Just tried and it worked.

https://github.com/llvm/llvm-project/pull/106164


More information about the Mlir-commits mailing list