[Mlir-commits] [mlir] [mlir][vector][nfc] Clean-up VectorOps.{h|cpp} (PR #109316)

Andrzej WarzyƄski llvmlistbot at llvm.org
Thu Sep 19 11:55:55 PDT 2024


https://github.com/banach-space updated https://github.com/llvm/llvm-project/pull/109316

>From b61f948d32904d78cffe6efcd6f49925dc3bc68e Mon Sep 17 00:00:00 2001
From: Andrzej Warzynski <andrzej.warzynski at arm.com>
Date: Thu, 19 Sep 2024 19:09:15 +0100
Subject: [PATCH] [mlir][vector][nfc] Clean-up VectorOps.{h|cpp}

* Removes the declaration of `getAsConstantIndexOps` - this method is
  neither defined nor used.
* Moves the definition of `getConstantVscaleMultiplier` near other
  helper hooks so that the order of definitions matches the order of
  declarations.
---
 .../mlir/Dialect/Vector/IR/VectorOps.h        |  5 ----
 mlir/lib/Dialect/Vector/IR/VectorOps.cpp      | 30 +++++++++----------
 2 files changed, 15 insertions(+), 20 deletions(-)

diff --git a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h
index 3d29ce8246b966..98fb6075cbf329 100644
--- a/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h
+++ b/mlir/include/mlir/Dialect/Vector/IR/VectorOps.h
@@ -166,11 +166,6 @@ SmallVector<int64_t> getAsIntegers(ArrayRef<OpFoldResult> foldResults);
 SmallVector<Value> getAsValues(OpBuilder &builder, Location loc,
                                ArrayRef<OpFoldResult> foldResults);
 
-/// Returns the constant index ops in `values`. `values` are expected to be
-/// constant operations.
-SmallVector<arith::ConstantIndexOp>
-getAsConstantIndexOps(ArrayRef<Value> values);
-
 /// If `value` is a constant multiple of `vector.vscale` (e.g. `%cst *
 /// vector.vscale`), return the multiplier (`%cst`). Otherwise, return
 /// `std::nullopt`.
diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
index 1438ddd1028bb9..cac6b955457049 100644
--- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
@@ -351,6 +351,21 @@ SmallVector<Value> vector::getAsValues(OpBuilder &builder, Location loc,
   return values;
 }
 
+std::optional<int64_t> vector::getConstantVscaleMultiplier(Value value) {
+  if (value.getDefiningOp<vector::VectorScaleOp>())
+    return 1;
+  auto mul = value.getDefiningOp<arith::MulIOp>();
+  if (!mul)
+    return {};
+  auto lhs = mul.getLhs();
+  auto rhs = mul.getRhs();
+  if (lhs.getDefiningOp<vector::VectorScaleOp>())
+    return getConstantIntValue(rhs);
+  if (rhs.getDefiningOp<vector::VectorScaleOp>())
+    return getConstantIntValue(lhs);
+  return {};
+}
+
 //===----------------------------------------------------------------------===//
 // CombiningKindAttr
 //===----------------------------------------------------------------------===//
@@ -5894,21 +5909,6 @@ LogicalResult CreateMaskOp::verify() {
   return success();
 }
 
-std::optional<int64_t> vector::getConstantVscaleMultiplier(Value value) {
-  if (value.getDefiningOp<vector::VectorScaleOp>())
-    return 1;
-  auto mul = value.getDefiningOp<arith::MulIOp>();
-  if (!mul)
-    return {};
-  auto lhs = mul.getLhs();
-  auto rhs = mul.getRhs();
-  if (lhs.getDefiningOp<vector::VectorScaleOp>())
-    return getConstantIntValue(rhs);
-  if (rhs.getDefiningOp<vector::VectorScaleOp>())
-    return getConstantIntValue(lhs);
-  return {};
-}
-
 namespace {
 
 /// Pattern to rewrite a CreateMaskOp with a ConstantMaskOp.



More information about the Mlir-commits mailing list