diff options
author | Florian Hahn <flo@fhahn.com> | 2020-10-15 21:50:56 +0100 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2020-10-15 22:02:17 +0100 |
commit | 89c0124273339076b25bf860f6c2ee765ab96db3 (patch) | |
tree | d25dee4c7eae022811df1a72511e8106648a9b67 /llvm/lib/Transforms/Utils/LoopVersioning.cpp | |
parent | 65cb4fdd69f43b6c39a8e4ca27b509284b11d807 (diff) | |
download | llvm-89c0124273339076b25bf860f6c2ee765ab96db3.zip llvm-89c0124273339076b25bf860f6c2ee765ab96db3.tar.gz llvm-89c0124273339076b25bf860f6c2ee765ab96db3.tar.bz2 |
[LoopVersion] Unify SCEVChecks and alias check handling (NFC).
This is an initial cleanup of the way LoopVersioning interacts with LAA.
Currently LoopVersioning has 2 ways of initializing things:
1. Passing LAI and passing UseLAIChecks = true
2. Passing UseLAIChecks = false, followed by calling setSCEVChecks and
setAliasChecks.
Both ways of initializing lead to the same result and the duplication
seems more complicated than necessary.
This patch removes the UseLAIChecks flag from the constructor and the
setSCEVChecks & setAliasChecks helpers and move initialization
exclusively to the constructor.
This simplifies things, by providing a single way to initialize
LoopVersioning and reducing duplication.
Reviewed By: Meinersbur, lebedev.ri
Differential Revision: https://reviews.llvm.org/D84406
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopVersioning.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopVersioning.cpp | 29 |
1 files changed, 10 insertions, 19 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopVersioning.cpp b/llvm/lib/Transforms/Utils/LoopVersioning.cpp index cd92f6d..f3170a1 100644 --- a/llvm/lib/Transforms/Utils/LoopVersioning.cpp +++ b/llvm/lib/Transforms/Utils/LoopVersioning.cpp @@ -37,25 +37,16 @@ static cl::opt<bool> cl::desc("Add no-alias annotation for instructions that " "are disambiguated by memchecks")); -LoopVersioning::LoopVersioning(const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI, - DominatorTree *DT, ScalarEvolution *SE, - bool UseLAIChecks) - : VersionedLoop(L), NonVersionedLoop(nullptr), LAI(LAI), LI(LI), DT(DT), +LoopVersioning::LoopVersioning(const LoopAccessInfo &LAI, + ArrayRef<RuntimePointerCheck> Checks, Loop *L, + LoopInfo *LI, DominatorTree *DT, + ScalarEvolution *SE) + : VersionedLoop(L), NonVersionedLoop(nullptr), + AliasChecks(Checks.begin(), Checks.end()), + Preds(LAI.getPSE().getUnionPredicate()), LAI(LAI), LI(LI), DT(DT), SE(SE) { assert(L->getExitBlock() && "No single exit block"); assert(L->isLoopSimplifyForm() && "Loop is not in loop-simplify form"); - if (UseLAIChecks) { - setAliasChecks(LAI.getRuntimePointerChecking()->getChecks()); - setSCEVChecks(LAI.getPSE().getUnionPredicate()); - } -} - -void LoopVersioning::setAliasChecks(ArrayRef<RuntimePointerCheck> Checks) { - AliasChecks = {Checks.begin(), Checks.end()}; -} - -void LoopVersioning::setSCEVChecks(SCEVUnionPredicate Check) { - Preds = std::move(Check); } void LoopVersioning::versionLoop( @@ -72,11 +63,10 @@ void LoopVersioning::versionLoop( addRuntimeChecks(RuntimeCheckBB->getTerminator(), VersionedLoop, AliasChecks, RtPtrChecking.getSE()); - const SCEVUnionPredicate &Pred = LAI.getPSE().getUnionPredicate(); SCEVExpander Exp(*SE, RuntimeCheckBB->getModule()->getDataLayout(), "scev.check"); SCEVRuntimeCheck = - Exp.expandCodeForPredicate(&Pred, RuntimeCheckBB->getTerminator()); + Exp.expandCodeForPredicate(&Preds, RuntimeCheckBB->getTerminator()); auto *CI = dyn_cast<ConstantInt>(SCEVRuntimeCheck); // Discard the SCEV runtime check if it is always true. @@ -278,7 +268,8 @@ bool runImpl(LoopInfo *LI, function_ref<const LoopAccessInfo &(Loop &)> GetLAA, if (L->isLoopSimplifyForm() && !LAI.hasConvergentOp() && (LAI.getNumRuntimePointerChecks() || !LAI.getPSE().getUnionPredicate().isAlwaysTrue())) { - LoopVersioning LVer(LAI, L, LI, DT, SE); + LoopVersioning LVer(LAI, LAI.getRuntimePointerChecking()->getChecks(), L, + LI, DT, SE); LVer.versionLoop(); LVer.annotateLoopWithNoAlias(); Changed = true; |