[Mlir-commits] [mlir] [mlir][scf]: Expose emitNormalizedLoopBounds/denormalizeInductionVariable util functions (NFC) (PR #94429)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Wed Jun 12 17:33:06 PDT 2024


================
@@ -100,6 +100,16 @@ llvm::SmallBitVector mlir::getPositionsOfShapeOne(unsigned rank,
   return dimsToProject;
 }
 
+Value mlir::getValueOrCreateConstantOp(OpBuilder &b, Location loc,
+                                       Type targetType, OpFoldResult ofr) {
+  if (auto value = llvm::dyn_cast_if_present<Value>(ofr))
+    return value;
+  auto attr = dyn_cast<IntegerAttr>(llvm::dyn_cast_if_present<Attribute>(ofr));
----------------
MaheshRavishankar wrote:

Because `OpFoldResult` is a mix of `Value` and `Attribute` and needs conversion to `IntegerAttr`. But you could use `cast<IntergerAttr>` and drop the subsequent assert

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


More information about the Mlir-commits mailing list