[Mlir-commits] [mlir] [MLIR] Remove UtilsDialect dep on ArithUtils (PR #85919)
Thomas Preud'homme
llvmlistbot at llvm.org
Wed Mar 20 04:23:02 PDT 2024
https://github.com/RoboTux created https://github.com/llvm/llvm-project/pull/85919
This will reduce the amount of libraries pulled through the de facto
dependency of TilingInterface on UtilsDialect for its IteratorType.
>From e9462c757e0f308e9d44ea6d49fd28f88ef845f7 Mon Sep 17 00:00:00 2001
From: Thomas Preud'homme <thomas.preudhomme at arm.com>
Date: Fri, 8 Mar 2024 16:35:58 +0000
Subject: [PATCH] [MLIR] Remove UtilsDialect dep on ArithUtils
This will reduce the amount of libraries pulled through the de facto
dependency of TilingInterface on UtilsDialect for its IteratorType.
---
mlir/include/mlir/Dialect/Utils/StaticValueUtils.h | 1 +
mlir/lib/Dialect/Utils/CMakeLists.txt | 4 +++-
mlir/lib/Dialect/Utils/StaticValueUtils.cpp | 12 ++++--------
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h b/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
index 1dc0398494dccf..20f019666a2e6a 100644
--- a/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
+++ b/mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
@@ -15,6 +15,7 @@
#ifndef MLIR_DIALECT_UTILS_STATICVALUEUTILS_H
#define MLIR_DIALECT_UTILS_STATICVALUEUTILS_H
+#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Support/LLVM.h"
diff --git a/mlir/lib/Dialect/Utils/CMakeLists.txt b/mlir/lib/Dialect/Utils/CMakeLists.txt
index 7d40caebe1e053..a0096e5f299d59 100644
--- a/mlir/lib/Dialect/Utils/CMakeLists.txt
+++ b/mlir/lib/Dialect/Utils/CMakeLists.txt
@@ -4,7 +4,9 @@ add_mlir_library(MLIRDialectUtils
StructuredOpsUtils.cpp
StaticValueUtils.cpp
+ DEPENDS
+ MLIRDialectUtilsIncGen
+
LINK_LIBS PUBLIC
- MLIRArithUtils
MLIRIR
)
diff --git a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp
index 0c8a88da789e26..1e8197e1094424 100644
--- a/mlir/lib/Dialect/Utils/StaticValueUtils.cpp
+++ b/mlir/lib/Dialect/Utils/StaticValueUtils.cpp
@@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//
#include "mlir/Dialect/Utils/StaticValueUtils.h"
-#include "mlir/Dialect/Arith/Utils/Utils.h"
#include "mlir/IR/Matchers.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Support/MathExtras.h"
@@ -18,13 +17,10 @@ namespace mlir {
bool isZeroIndex(OpFoldResult v) {
if (!v)
return false;
- if (auto attr = llvm::dyn_cast_if_present<Attribute>(v)) {
- IntegerAttr intAttr = dyn_cast<IntegerAttr>(attr);
- return intAttr && intAttr.getValue().isZero();
- }
- if (auto cst = v.get<Value>().getDefiningOp<arith::ConstantIndexOp>())
- return cst.value() == 0;
- return false;
+ std::optional<int64_t> constint = getConstantIntValue(v);
+ if (!constint)
+ return false;
+ return *constint == 0;
}
std::tuple<SmallVector<OpFoldResult>, SmallVector<OpFoldResult>,
More information about the Mlir-commits
mailing list