Skip to content

[SYCL][NATIVECPU] Schedule optimization passes in Native CPU pipeline #14380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion llvm/lib/SYCLNativeCPUUtils/PipelineSYCLNativeCPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@
#include "compiler/utils/work_item_loops_pass.h"
#include "vecz/pass.h"
#include "vecz/vecz_target_info.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Transforms/AggressiveInstCombine/AggressiveInstCombine.h"
#include "llvm/Transforms/IPO/AlwaysInliner.h"
#include "llvm/Transforms/Scalar/DCE.h"
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/SROA.h"
#include "llvm/Transforms/Scalar/SimplifyCFG.h"
#endif

using namespace llvm;
Expand Down Expand Up @@ -65,6 +71,7 @@ void llvm::sycl::utils::addSYCLNativeCPUBackendPasses(
MPM.addPass(SpecConstantsPass(SpecConstantsPass::HandlingMode::emulation));
MPM.addPass(ConvertToMuxBuiltinsSYCLNativeCPUPass());
#ifdef NATIVECPU_USE_OCK
MPM.addPass(compiler::utils::PrepareBarriersPass());
MPM.addPass(compiler::utils::TransferKernelMetadataPass());
MPM.addPass(FixABIMuxBuiltinsPass());
// Always enable vectorizer, unless explictly disabled or -O0 is set.
Expand All @@ -86,13 +93,20 @@ void llvm::sycl::utils::addSYCLNativeCPUBackendPasses(
MAM.registerPass(
[QueryFunc] { return vecz::VeczPassOptionsAnalysis(QueryFunc); });
MPM.addPass(vecz::RunVeczPass());
FunctionPassManager FPM;
FPM.addPass(SimplifyCFGPass());
FPM.addPass(SROAPass(SROAOptions::ModifyCFG));
FPM.addPass(AggressiveInstCombinePass());
FPM.addPass(GVNPass(GVNOptions().setMemDep(true)));
FPM.addPass(DCEPass());
FPM.addPass(SimplifyCFGPass());
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
}
compiler::utils::WorkItemLoopsPassOptions Opts;
Opts.IsDebug = IsDebug;
Opts.ForceNoTail = ForceNoTail;
MAM.registerPass([] { return compiler::utils::BuiltinInfoAnalysis(); });
MAM.registerPass([] { return compiler::utils::SubgroupAnalysis(); });
MPM.addPass(compiler::utils::PrepareBarriersPass());
MPM.addPass(compiler::utils::WorkItemLoopsPass(Opts));
MPM.addPass(compiler::utils::ReplaceLocalModuleScopeVariablesPass());
MPM.addPass(AlwaysInlinerPass());
Expand Down
Loading