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 15
15
#ifndef MLIR_DIALECT_UTILS_STATICVALUEUTILS_H
16
16
#define MLIR_DIALECT_UTILS_STATICVALUEUTILS_H
17
17
18
+ #include " mlir/IR/Builders.h"
18
19
#include " mlir/IR/BuiltinAttributes.h"
19
20
#include " mlir/IR/OpDefinition.h"
20
21
#include " mlir/Support/LLVM.h"
Original file line number Diff line number Diff line change @@ -4,7 +4,9 @@ add_mlir_library(MLIRDialectUtils
4
4
StructuredOpsUtils.cpp
5
5
StaticValueUtils.cpp
6
6
7
+ DEPENDS
8
+ MLIRDialectUtilsIncGen
9
+
7
10
LINK_LIBS PUBLIC
8
- MLIRArithUtils
9
11
MLIRIR
10
12
)
Original file line number Diff line number Diff line change 7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " mlir/Dialect/Utils/StaticValueUtils.h"
10
- #include " mlir/Dialect/Arith/Utils/Utils.h"
11
10
#include " mlir/IR/Matchers.h"
12
11
#include " mlir/Support/LLVM.h"
13
12
#include " mlir/Support/MathExtras.h"
@@ -18,13 +17,10 @@ namespace mlir {
18
17
bool isZeroIndex (OpFoldResult v) {
19
18
if (!v)
20
19
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 ;
28
24
}
29
25
30
26
std::tuple<SmallVector<OpFoldResult>, SmallVector<OpFoldResult>,
You can’t perform that action at this time.
0 commit comments