Skip to content

Commit

Permalink
[MLIR] Remove UtilsDialect dep on ArithUtils (llvm#85919)
Browse files Browse the repository at this point in the history
This will reduce the amount of libraries pulled through the de facto
dependency of TilingInterface on UtilsDialect for its IteratorType.
  • Loading branch information
RoboTux authored and chencha3 committed Mar 22, 2024
1 parent 09b7118 commit 7be1e8a
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
1 change: 1 addition & 0 deletions mlir/include/mlir/Dialect/Utils/StaticValueUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion mlir/lib/Dialect/Utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ add_mlir_library(MLIRDialectUtils
StructuredOpsUtils.cpp
StaticValueUtils.cpp

DEPENDS
MLIRDialectUtilsIncGen

LINK_LIBS PUBLIC
MLIRArithUtils
MLIRIR
)
12 changes: 4 additions & 8 deletions mlir/lib/Dialect/Utils/StaticValueUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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>,
Expand Down

0 comments on commit 7be1e8a

Please sign in to comment.