From ab27aefdc53a573e9793369e85a397342e172b63 Mon Sep 17 00:00:00 2001 From: Hanhan Wang Date: Wed, 23 Aug 2023 15:47:43 -0700 Subject: [PATCH] Disable hoisting target-dependent ops to globals --- .../compiler/Dialect/Util/Analysis/Constant/BUILD.bazel | 2 ++ .../Dialect/Util/Analysis/Constant/CMakeLists.txt | 2 ++ .../compiler/Dialect/Util/Analysis/Constant/OpOracle.cpp | 8 ++++++++ 3 files changed, 12 insertions(+) diff --git a/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/BUILD.bazel b/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/BUILD.bazel index 47bcaa17ab19..58c86e1cf430 100644 --- a/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/BUILD.bazel +++ b/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/BUILD.bazel @@ -23,8 +23,10 @@ iree_compiler_cc_library( "OpOracle.h", ], deps = [ + "//compiler/src/iree/compiler/Codegen/Dialect:IREECodegenDialect", "//compiler/src/iree/compiler/Dialect/Util/Analysis", "//compiler/src/iree/compiler/Dialect/Util/IR", + "//llvm-external-projects/iree-dialects:IREELinalgExtDialect", "@llvm-project//llvm:Support", "@llvm-project//mlir:ArithDialect", "@llvm-project//mlir:FuncDialect", diff --git a/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/CMakeLists.txt b/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/CMakeLists.txt index 9fe654f320ef..48bfef0585ff 100644 --- a/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/CMakeLists.txt +++ b/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/CMakeLists.txt @@ -20,6 +20,7 @@ iree_cc_library( "ConstExpr.cpp" "OpOracle.cpp" DEPS + IREELinalgExtDialect LLVMSupport MLIRArithDialect MLIRFuncDialect @@ -27,6 +28,7 @@ iree_cc_library( MLIRLinalgDialect MLIRSupport MLIRTensorDialect + iree::compiler::Codegen::Dialect::IREECodegenDialect iree::compiler::Dialect::Util::Analysis iree::compiler::Dialect::Util::IR PUBLIC diff --git a/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/OpOracle.cpp b/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/OpOracle.cpp index 5b812b4c614a..6351073257a5 100644 --- a/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/OpOracle.cpp +++ b/compiler/src/iree/compiler/Dialect/Util/Analysis/Constant/OpOracle.cpp @@ -6,6 +6,8 @@ #include "iree/compiler/Dialect/Util/Analysis/Constant/OpOracle.h" +#include "iree-dialects/Dialect/LinalgExt/IR/LinalgExtOps.h" +#include "iree/compiler/Codegen/Dialect/IREECodegenOps.h" #include "iree/compiler/Dialect/Util/IR/UtilDialect.h" #include "iree/compiler/Dialect/Util/IR/UtilOps.h" #include "llvm/ADT/SmallPtrSet.h" @@ -100,6 +102,12 @@ ConstExprOpInfo ConstExprOpInfo::getForOp(Operation *op) { return {}; } + // Target-dependent ops are not const-expr. + if (isa(op)) { + return {}; + } + // By default, ops without results are not const-expr. if (op->getNumResults() == 0) { return {};