[Mlir-commits] [mlir] [MLIR][VectorToLLVM] Handle scalable dim in createVectorLengthValue() (PR #93361)

Andrzej WarzyƄski llvmlistbot at llvm.org
Wed May 29 10:50:04 PDT 2024


================
@@ -532,9 +532,19 @@ static Value createVectorLengthValue(ConversionPatternRewriter &rewriter,
   auto vShape = vType.getShape();
   assert(vShape.size() == 1 && "Unexpected multi-dim vector type");
 
-  return rewriter.create<LLVM::ConstantOp>(
+  Value vLen = rewriter.create<LLVM::ConstantOp>(
       loc, rewriter.getI32Type(),
       rewriter.getIntegerAttr(rewriter.getI32Type(), vShape[0]));
+
+  if (!vType.getScalableDims()[0])
+    return vLen;
+
+  // Create VScale*vShape[0] and return it as vector length.
----------------
banach-space wrote:

[nit] We tend to write "vscale" rather than VScale. Also, why `Shape` rather than `shape[0]` or (even better, referring to a C++ variable): `vShape[0]`. In fact, you could rename `vLen` as `baseVecLength` to make the variable names more descriptive and use that in the comment.

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


More information about the Mlir-commits mailing list