[Mlir-commits] [mlir] [mlir][Vector] Fold vector.constant_mask to SplatElementsAttr (PR #146724)

Jakub Kuderski llvmlistbot at llvm.org
Wed Jul 2 09:07:00 PDT 2025


================
@@ -6594,6 +6594,26 @@ bool ConstantMaskOp::isAllOnesMask() {
   return true;
 }
 
+static Attribute createBoolSplat(ShapedType ty, bool x) {
+  return SplatElementsAttr::get(ty, BoolAttr::get(ty.getContext(), x));
+}
+
+OpFoldResult ConstantMaskOp::fold(FoldAdaptor adaptor) {
+  ArrayRef<int64_t> bounds = getMaskDimSizes();
+  ArrayRef<int64_t> vectorSizes = getVectorType().getShape();
+  // Check the corner case of 0-D vectors first.
+  if (vectorSizes.size() == 0) {
----------------
kuhar wrote:

```suggestion
  if (vectorSizes.empty()) {
```

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


More information about the Mlir-commits mailing list