1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00

[TI removal] Switch simple loop unswitch to Instruction.

llvm-svn: 344719
This commit is contained in:
Chandler Carruth 2018-10-18 00:40:26 +00:00
parent cffe8b9b1e
commit 570e81c3e3

View File

@ -1793,7 +1793,7 @@ void visitDomSubTree(DominatorTree &DT, BasicBlock *BB, CallableT Callable) {
}
static bool unswitchNontrivialInvariants(
Loop &L, TerminatorInst &TI, ArrayRef<Value *> Invariants,
Loop &L, Instruction &TI, ArrayRef<Value *> Invariants,
DominatorTree &DT, LoopInfo &LI, AssumptionCache &AC,
function_ref<void(bool, ArrayRef<Loop *>)> UnswitchCB,
ScalarEvolution *SE) {
@ -2188,7 +2188,7 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI,
ScalarEvolution *SE) {
// Collect all invariant conditions within this loop (as opposed to an inner
// loop which would be handled when visiting that inner loop).
SmallVector<std::pair<TerminatorInst *, TinyPtrVector<Value *>>, 4>
SmallVector<std::pair<Instruction *, TinyPtrVector<Value *>>, 4>
UnswitchCandidates;
for (auto *BB : L.blocks()) {
if (LI.getLoopFor(BB) != &L)
@ -2298,7 +2298,7 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI,
SmallDenseMap<DomTreeNode *, int, 4> DTCostMap;
// Given a terminator which might be unswitched, computes the non-duplicated
// cost for that terminator.
auto ComputeUnswitchedCost = [&](TerminatorInst &TI, bool FullUnswitch) {
auto ComputeUnswitchedCost = [&](Instruction &TI, bool FullUnswitch) {
BasicBlock &BB = *TI.getParent();
SmallPtrSet<BasicBlock *, 4> Visited;
@ -2349,11 +2349,11 @@ unswitchBestCondition(Loop &L, DominatorTree &DT, LoopInfo &LI,
"Cannot unswitch a condition without multiple distinct successors!");
return Cost * (Visited.size() - 1);
};
TerminatorInst *BestUnswitchTI = nullptr;
Instruction *BestUnswitchTI = nullptr;
int BestUnswitchCost;
ArrayRef<Value *> BestUnswitchInvariants;
for (auto &TerminatorAndInvariants : UnswitchCandidates) {
TerminatorInst &TI = *TerminatorAndInvariants.first;
Instruction &TI = *TerminatorAndInvariants.first;
ArrayRef<Value *> Invariants = TerminatorAndInvariants.second;
BranchInst *BI = dyn_cast<BranchInst>(&TI);
int CandidateCost = ComputeUnswitchedCost(