[Mlir-commits] [mlir] [mlir][memref] Refactor `ViewOpShapeFolder` (PR #176567)
Jakub Kuderski
llvmlistbot at llvm.org
Sat Jan 17 07:02:57 PST 2026
================
@@ -3763,71 +3763,69 @@ OpFoldResult ViewOp::fold(FoldAdaptor adaptor) {
}
namespace {
+/// Given a memref type and a range of values that defines its dynamic
+/// dimension sizes, turn all dynamic sizes that have a constant value into
+/// static dimension sizes.
+static MemRefType
+foldDynamicToStaticDimSizes(MemRefType type, ValueRange dynamicSizes,
+ SmallVector<Value> &foldedDynamicSizes) {
+ SmallVector<int64_t> staticShape(type.getShape());
+ assert(type.getNumDynamicDims() == dynamicSizes.size() &&
+ "incorrect number of dynamic sizes");
+
+ // Compute new static and dynamic sizes.
+ unsigned ctr = 0;
+ for (int64_t i = 0, e = type.getRank(); i < e; ++i) {
+ if (type.isDynamicDim(i)) {
----------------
kuhar wrote:
Check for `isStaticDim` and `continue` early instead. See https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code
https://github.com/llvm/llvm-project/pull/176567
More information about the Mlir-commits
mailing list