diff options
author | Siddharth Bhat <siddu.druid@gmail.com> | 2017-07-06 13:42:42 +0000 |
---|---|---|
committer | Siddharth Bhat <siddu.druid@gmail.com> | 2017-07-06 13:42:42 +0000 |
commit | 761e5b9310c8ca101c26909a24c440bfc69bf827 (patch) | |
tree | 8bd0dc28eeabdcbb2618c8651c4b78ed98ac4a96 /polly/lib/CodeGen/PPCGCodeGeneration.cpp | |
parent | 9c3e2eac6a5e48962250342c72989e321e889607 (diff) | |
download | bcm5719-llvm-761e5b9310c8ca101c26909a24c440bfc69bf827.tar.gz bcm5719-llvm-761e5b9310c8ca101c26909a24c440bfc69bf827.zip |
[Polly] [PPCGCodeGeneration] Teach `must_kills` to kill scalars that are local to the scop.
- By definition, we can pass something as a `kill` to PPCG if we know
that no data can flow across a kill.
- This is useful for more complex examples where we have scalars that
are local to a scop.
- If the local is only used within a scop, we are free to kill it.
Differential Revision: https://reviews.llvm.org/D35045
llvm-svn: 307260
Diffstat (limited to 'polly/lib/CodeGen/PPCGCodeGeneration.cpp')
-rw-r--r-- | polly/lib/CodeGen/PPCGCodeGeneration.cpp | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/polly/lib/CodeGen/PPCGCodeGeneration.cpp b/polly/lib/CodeGen/PPCGCodeGeneration.cpp index 4e49d1c46ff..d2e4b2b72e7 100644 --- a/polly/lib/CodeGen/PPCGCodeGeneration.cpp +++ b/polly/lib/CodeGen/PPCGCodeGeneration.cpp @@ -138,6 +138,25 @@ struct MustKillsInfo { MustKillsInfo() : KillsSchedule(nullptr), TaggedMustKills(nullptr){}; }; +/// Check if SAI's uses are entirely contained within Scop S. +/// If a scalar is used only with a Scop, we are free to kill it, as no data +/// can flow in/out of the value any more. +/// @see computeMustKillsInfo +static bool isScalarUsesContainedInScop(const Scop &S, + const ScopArrayInfo *SAI) { + assert(SAI->isValueKind() && "this function only deals with scalars." + " Dealing with arrays required alias analysis"); + + const Region &R = S.getRegion(); + for (User *U : SAI->getBasePtr()->users()) { + Instruction *I = dyn_cast<Instruction>(U); + assert(I && "invalid user of scop array info"); + if (!R.contains(I)) + return false; + } + return true; +} + /// Compute must-kills needed to enable live range reordering with PPCG. /// /// @params S The Scop to compute live range reordering information @@ -147,13 +166,14 @@ static MustKillsInfo computeMustKillsInfo(const Scop &S) { const isl::space ParamSpace(isl::manage(S.getParamSpace())); MustKillsInfo Info; - // 1. Collect phi nodes in scop. + // 1. Collect all ScopArrayInfo that satisfy *any* of the criteria: + // 1.1 phi nodes in scop. + // 1.2 scalars that are only used within the scop SmallVector<isl::id, 4> KillMemIds; for (ScopArrayInfo *SAI : S.arrays()) { - if (!SAI->isPHIKind()) - continue; - - KillMemIds.push_back(isl::manage(SAI->getBasePtrId())); + if (SAI->isPHIKind() || + (SAI->isValueKind() && isScalarUsesContainedInScop(S, SAI))) + KillMemIds.push_back(isl::manage(SAI->getBasePtrId())); } Info.TaggedMustKills = isl::union_map::empty(isl::space(ParamSpace)); |