mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
[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
This commit is contained in:
parent
641403f550
commit
cea367bb2a
@ -43,9 +43,9 @@ public:
|
||||
/// It uses runtime check provided by the user. If \p UseLAIChecks is true,
|
||||
/// we will retain the default checks made by LAI. Otherwise, construct an
|
||||
/// object having no checks and we expect the user to add them.
|
||||
LoopVersioning(const LoopAccessInfo &LAI, Loop *L, LoopInfo *LI,
|
||||
DominatorTree *DT, ScalarEvolution *SE,
|
||||
bool UseLAIChecks = true);
|
||||
LoopVersioning(const LoopAccessInfo &LAI,
|
||||
ArrayRef<RuntimePointerCheck> Checks, Loop *L, LoopInfo *LI,
|
||||
DominatorTree *DT, ScalarEvolution *SE);
|
||||
|
||||
/// Performs the CFG manipulation part of versioning the loop including
|
||||
/// the DominatorTree and LoopInfo updates.
|
||||
@ -75,12 +75,6 @@ public:
|
||||
/// loop may alias (i.e. one of the memchecks failed).
|
||||
Loop *getNonVersionedLoop() { return NonVersionedLoop; }
|
||||
|
||||
/// Sets the runtime alias checks for versioning the loop.
|
||||
void setAliasChecks(ArrayRef<RuntimePointerCheck> Checks);
|
||||
|
||||
/// Sets the runtime SCEV checks for versioning the loop.
|
||||
void setSCEVChecks(SCEVUnionPredicate Check);
|
||||
|
||||
/// Annotate memory instructions in the versioned loop with no-alias
|
||||
/// metadata based on the memchecks issued.
|
||||
///
|
||||
@ -129,7 +123,7 @@ private:
|
||||
SmallVector<RuntimePointerCheck, 4> AliasChecks;
|
||||
|
||||
/// The set of SCEV checks that we are versioning for.
|
||||
SCEVUnionPredicate Preds;
|
||||
const SCEVUnionPredicate &Preds;
|
||||
|
||||
/// Maps a pointer to the pointer checking group that the pointer
|
||||
/// belongs to.
|
||||
|
@ -814,9 +814,7 @@ public:
|
||||
|
||||
LLVM_DEBUG(dbgs() << "\nPointers:\n");
|
||||
LLVM_DEBUG(LAI->getRuntimePointerChecking()->printChecks(dbgs(), Checks));
|
||||
LoopVersioning LVer(*LAI, L, LI, DT, SE, false);
|
||||
LVer.setAliasChecks(std::move(Checks));
|
||||
LVer.setSCEVChecks(LAI->getPSE().getUnionPredicate());
|
||||
LoopVersioning LVer(*LAI, Checks, L, LI, DT, SE);
|
||||
LVer.versionLoop(DefsUsedOutside);
|
||||
LVer.annotateLoopWithNoAlias();
|
||||
|
||||
|
@ -563,9 +563,7 @@ public:
|
||||
// Point of no-return, start the transformation. First, version the loop
|
||||
// if necessary.
|
||||
|
||||
LoopVersioning LV(LAI, L, LI, DT, PSE.getSE(), false);
|
||||
LV.setAliasChecks(std::move(Checks));
|
||||
LV.setSCEVChecks(LAI.getPSE().getUnionPredicate());
|
||||
LoopVersioning LV(LAI, Checks, L, LI, DT, PSE.getSE());
|
||||
LV.versionLoop();
|
||||
|
||||
// After versioning, some of the candidates' pointers could stop being
|
||||
|
@ -601,7 +601,8 @@ bool LoopVersioningLICM::runOnLoop(Loop *L, LPPassManager &LPM) {
|
||||
// Create memcheck for memory accessed inside loop.
|
||||
// Clone original loop, and set blocks properly.
|
||||
DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
|
||||
LoopVersioning LVer(*LAI, CurLoop, LI, DT, SE, true);
|
||||
LoopVersioning LVer(*LAI, LAI->getRuntimePointerChecking()->getChecks(),
|
||||
CurLoop, LI, DT, SE);
|
||||
LVer.versionLoop();
|
||||
// Set Loop Versioning metaData for original loop.
|
||||
addStringMetadataToLoop(LVer.getNonVersionedLoop(), LICMVersioningMetaData);
|
||||
|
@ -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;
|
||||
|
@ -2986,8 +2986,10 @@ void InnerLoopVectorizer::emitMemRuntimeChecks(Loop *L, BasicBlock *Bypass) {
|
||||
|
||||
// We currently don't use LoopVersioning for the actual loop cloning but we
|
||||
// still use it to add the noalias metadata.
|
||||
LVer = std::make_unique<LoopVersioning>(*Legal->getLAI(), OrigLoop, LI, DT,
|
||||
PSE.getSE());
|
||||
LVer = std::make_unique<LoopVersioning>(
|
||||
*Legal->getLAI(),
|
||||
Legal->getLAI()->getRuntimePointerChecking()->getChecks(), OrigLoop, LI,
|
||||
DT, PSE.getSE());
|
||||
LVer->prepareNoAliasMetadata();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user