Skip to content

Commit b74248d

Browse files
committed
[InstCombine] Pass RPOT to InstCombiner (NFC)
To make use of it in a followup change.
1 parent 03e0be9 commit b74248d

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

llvm/include/llvm/Transforms/InstCombine/InstCombiner.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
8484
// combining and will be updated to reflect any changes.
8585
LoopInfo *LI;
8686

87+
ReversePostOrderTraversal<BasicBlock *> &RPOT;
88+
8789
bool MadeIRChange = false;
8890

8991
/// Edges that are known to never be taken.
@@ -98,12 +100,13 @@ class LLVM_LIBRARY_VISIBILITY InstCombiner {
98100
TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
99101
DominatorTree &DT, OptimizationRemarkEmitter &ORE,
100102
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI,
101-
ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI)
103+
ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI,
104+
ReversePostOrderTraversal<BasicBlock *> &RPOT)
102105
: TTI(TTI), Builder(Builder), Worklist(Worklist),
103106
MinimizeSize(MinimizeSize), AA(AA), AC(AC), TLI(TLI), DT(DT), DL(DL),
104107
SQ(DL, &TLI, &DT, &AC, nullptr, /*UseInstrInfo*/ true,
105108
/*CanUseUndef*/ true, &DC),
106-
ORE(ORE), BFI(BFI), BPI(BPI), PSI(PSI), LI(LI) {}
109+
ORE(ORE), BFI(BFI), BPI(BPI), PSI(PSI), LI(LI), RPOT(RPOT) {}
107110

108111
virtual ~InstCombiner() = default;
109112

llvm/lib/Transforms/InstCombine/InstCombineInternal.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
6666
TargetLibraryInfo &TLI, TargetTransformInfo &TTI,
6767
DominatorTree &DT, OptimizationRemarkEmitter &ORE,
6868
BlockFrequencyInfo *BFI, BranchProbabilityInfo *BPI,
69-
ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI)
69+
ProfileSummaryInfo *PSI, const DataLayout &DL, LoopInfo *LI,
70+
ReversePostOrderTraversal<BasicBlock *> &RPOT)
7071
: InstCombiner(Worklist, Builder, MinimizeSize, AA, AC, TLI, TTI, DT, ORE,
71-
BFI, BPI, PSI, DL, LI) {}
72+
BFI, BPI, PSI, DL, LI, RPOT) {}
7273

7374
virtual ~InstCombinerImpl() = default;
7475

7576
/// Perform early cleanup and prepare the InstCombine worklist.
76-
bool prepareWorklist(Function &F,
77-
ReversePostOrderTraversal<BasicBlock *> &RPOT);
77+
bool prepareWorklist(Function &F);
7878

7979
/// Run the combiner over the entire worklist until it is empty.
8080
///

llvm/lib/Transforms/InstCombine/InstructionCombining.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5234,8 +5234,7 @@ class AliasScopeTracker {
52345234
/// them to the worklist (this significantly speeds up instcombine on code where
52355235
/// many instructions are dead or constant). Additionally, if we find a branch
52365236
/// whose condition is a known constant, we only visit the reachable successors.
5237-
bool InstCombinerImpl::prepareWorklist(
5238-
Function &F, ReversePostOrderTraversal<BasicBlock *> &RPOT) {
5237+
bool InstCombinerImpl::prepareWorklist(Function &F) {
52395238
bool MadeIRChange = false;
52405239
SmallPtrSet<BasicBlock *, 32> LiveBlocks;
52415240
SmallVector<Instruction *, 128> InstrsForInstructionWorklist;
@@ -5417,9 +5416,9 @@ static bool combineInstructionsOverFunction(
54175416
<< F.getName() << "\n");
54185417

54195418
InstCombinerImpl IC(Worklist, Builder, F.hasMinSize(), AA, AC, TLI, TTI, DT,
5420-
ORE, BFI, BPI, PSI, DL, LI);
5419+
ORE, BFI, BPI, PSI, DL, LI, RPOT);
54215420
IC.MaxArraySizeForCombine = MaxArraySize;
5422-
bool MadeChangeInThisIteration = IC.prepareWorklist(F, RPOT);
5421+
bool MadeChangeInThisIteration = IC.prepareWorklist(F);
54235422
MadeChangeInThisIteration |= IC.run();
54245423
if (!MadeChangeInThisIteration)
54255424
break;

0 commit comments

Comments
 (0)