File tree Expand file tree Collapse file tree 3 files changed +8
-9
lines changed
include/mlir/Dialect/Utils Expand file tree Collapse file tree 3 files changed +8
-9
lines changed Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff 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)
Original file line number Diff line number Diff line change 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 {
1817bool 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
3026std::tuple<SmallVector<OpFoldResult>, SmallVector<OpFoldResult>,
You can’t perform that action at this time.
0 commit comments