Skip to content

Commit

Permalink
[SYCL][NATIVECPU] Schedule optimization passes in Native CPU pipeline…
Browse files Browse the repository at this point in the history
… (#14380)

Adds some extra optimization passes after vectorization on Native CPU.
  • Loading branch information
PietroGhg authored Oct 14, 2024
1 parent a5161f2 commit 552dc16
Showing 1 changed file with 15 additions and 1 deletion.
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

0 comments on commit 552dc16

Please sign in to comment.