Skip to content

Commit da2c98b

Browse files
authored
[MLIR] Remove UtilsDialect dep on ArithUtils (#85919)
This will reduce the amount of libraries pulled through the de facto dependency of TilingInterface on UtilsDialect for its IteratorType.
1 parent 357f00d commit da2c98b

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

mlir/include/mlir/Dialect/Utils/StaticValueUtils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#ifndef MLIR_DIALECT_UTILS_STATICVALUEUTILS_H
1616
#define MLIR_DIALECT_UTILS_STATICVALUEUTILS_H
1717

18+
#include "mlir/IR/Builders.h"
1819
#include "mlir/IR/BuiltinAttributes.h"
1920
#include "mlir/IR/OpDefinition.h"
2021
#include "mlir/Support/LLVM.h"

mlir/lib/Dialect/Utils/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ add_mlir_library(MLIRDialectUtils
44
StructuredOpsUtils.cpp
55
StaticValueUtils.cpp
66

7+
DEPENDS
8+
MLIRDialectUtilsIncGen
9+
710
LINK_LIBS PUBLIC
8-
MLIRArithUtils
911
MLIRIR
1012
)

mlir/lib/Dialect/Utils/StaticValueUtils.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
//===----------------------------------------------------------------------===//
88

99
#include "mlir/Dialect/Utils/StaticValueUtils.h"
10-
#include "mlir/Dialect/Arith/Utils/Utils.h"
1110
#include "mlir/IR/Matchers.h"
1211
#include "mlir/Support/LLVM.h"
1312
#include "mlir/Support/MathExtras.h"
@@ -18,13 +17,10 @@ namespace mlir {
1817
bool isZeroIndex(OpFoldResult v) {
1918
if (!v)
2019
return false;
21-
if (auto attr = llvm::dyn_cast_if_present<Attribute>(v)) {
22-
IntegerAttr intAttr = dyn_cast<IntegerAttr>(attr);
23-
return intAttr && intAttr.getValue().isZero();
24-
}
25-
if (auto cst = v.get<Value>().getDefiningOp<arith::ConstantIndexOp>())
26-
return cst.value() == 0;
27-
return false;
20+
std::optional<int64_t> constint = getConstantIntValue(v);
21+
if (!constint)
22+
return false;
23+
return *constint == 0;
2824
}
2925

3026
std::tuple<SmallVector<OpFoldResult>, SmallVector<OpFoldResult>,

0 commit comments

Comments
 (0)