Skip to content

Commit

Permalink
[LoopFuse] Change DT to reference in FusionCandidate struct. NFC
Browse files Browse the repository at this point in the history
Assertion added in f50821c confirms that the DT is indeed nonnull.
Change it to a reference instead of a pointer to make this explicit in
FusionCandidate.
Suggested in D118472.
  • Loading branch information
annamthomas committed Feb 2, 2022
1 parent faabdfc commit a73e4ce
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions llvm/lib/Transforms/Scalar/LoopFuse.cpp
Expand Up @@ -178,12 +178,12 @@ struct FusionCandidate {
/// FusionCandidateCompare function, required by FusionCandidateSet to
/// determine where the FusionCandidate should be inserted into the set. These
/// are used to establish ordering of the FusionCandidates based on dominance.
const DominatorTree *DT;
DominatorTree &DT;
const PostDominatorTree *PDT;

OptimizationRemarkEmitter &ORE;

FusionCandidate(Loop *L, const DominatorTree *DT,
FusionCandidate(Loop *L, DominatorTree &DT,
const PostDominatorTree *PDT, OptimizationRemarkEmitter &ORE,
TTI::PeelingPreferences PP)
: Preheader(L->getLoopPreheader()), Header(L->getHeader()),
Expand All @@ -192,7 +192,6 @@ struct FusionCandidate {
GuardBranch(L->getLoopGuardBranch()), PP(PP), AbleToPeel(canPeel(L)),
Peeled(false), DT(DT), PDT(PDT), ORE(ORE) {

assert(DT && "Expected non-null DT!");
// Walk over all blocks in the loop and check for conditions that may
// prevent fusion. For each block, walk over all instructions and collect
// the memory reads and writes If any instructions that prevent fusion are
Expand Down Expand Up @@ -391,7 +390,7 @@ struct FusionCandidateCompare {
/// IF RHS dominates LHS and LHS post-dominates RHS, return false;
bool operator()(const FusionCandidate &LHS,
const FusionCandidate &RHS) const {
const DominatorTree *DT = LHS.DT;
const DominatorTree *DT = &(LHS.DT);

BasicBlock *LHSEntryBlock = LHS.getEntryBlock();
BasicBlock *RHSEntryBlock = RHS.getEntryBlock();
Expand Down Expand Up @@ -646,7 +645,7 @@ struct LoopFuser {
for (Loop *L : LV) {
TTI::PeelingPreferences PP =
gatherPeelingPreferences(L, SE, TTI, None, None);
FusionCandidate CurrCand(L, &DT, &PDT, ORE, PP);
FusionCandidate CurrCand(L, DT, &PDT, ORE, PP);
if (!CurrCand.isEligibleForFusion(SE))
continue;

Expand Down Expand Up @@ -991,7 +990,7 @@ struct LoopFuser {
FuseCounter);

FusionCandidate FusedCand(
performFusion((Peel ? FC0Copy : *FC0), *FC1), &DT, &PDT, ORE,
performFusion((Peel ? FC0Copy : *FC0), *FC1), DT, &PDT, ORE,
FC0Copy.PP);
FusedCand.verify();
assert(FusedCand.isEligibleForFusion(SE) &&
Expand Down

0 comments on commit a73e4ce

Please sign in to comment.