Skip to content

[SYCL] Disable createIndVarSimplifyPass for SPIR target in SYCL mode. #2275

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 2 commits into from
Aug 7, 2020
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4106,6 +4106,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
if (!Args.hasFlag(options::OPT_fsycl_std_optimizations,
options::OPT_fno_sycl_std_optimizations, true))
CmdArgs.push_back("-fno-sycl-std-optimizations");
else if (RawTriple.isSPIR()) {
// Set `sycl-opt` option to configure LLVM passes for SPIR target
CmdArgs.push_back("-mllvm");
CmdArgs.push_back("-sycl-opt");
}

// Pass the triple of host when doing SYCL
auto AuxT = llvm::Triple(llvm::sys::getProcessTriple());
Expand Down
11 changes: 10 additions & 1 deletion llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ static cl::opt<bool>
RunLoopRerolling("reroll-loops", cl::Hidden,
cl::desc("Run the loop rerolling pass"));

static cl::opt<bool>
SYCLOptimizationMode("sycl-opt", cl::init(false), cl::Hidden,
cl::desc("Enable SYCL optimization mode."));

static cl::opt<bool> RunNewGVN("enable-newgvn", cl::init(false), cl::Hidden,
cl::desc("Run the NewGVN pass"));

Expand Down Expand Up @@ -429,7 +433,12 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
MPM.add(createCFGSimplificationPass());
MPM.add(createInstructionCombiningPass());
// We resume loop passes creating a second loop pipeline here.
MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
// TODO: this pass hurts performance due to promotions of induction variables
// from 32-bit value to 64-bit values. I assume it's because SPIR is a virtual
// target with unlimited # of registers and pass doesn't take into account
// that on real HW this promotion is not beneficial.
if (!SYCLOptimizationMode)
MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
addExtensionsToPM(EP_LateLoopOptimizations, MPM);
MPM.add(createLoopDeletionPass()); // Delete dead loops
Expand Down