[Transforms] Use llvm::pred_size and llvm::predecessors (NFC)

This commit is contained in:
Kazu Hirata 2024-01-24 00:27:35 -08:00
parent 5404a3792e
commit 873a7bb129

View File

@ -1431,16 +1431,14 @@ bool JumpThreadingPass::simplifyPartiallyRedundantLoad(LoadInst *LoadI) {
array_pod_sort(AvailablePreds.begin(), AvailablePreds.end());
// Create a PHI node at the start of the block for the PRE'd load value.
pred_iterator PB = pred_begin(LoadBB), PE = pred_end(LoadBB);
PHINode *PN = PHINode::Create(LoadI->getType(), std::distance(PB, PE), "");
PHINode *PN = PHINode::Create(LoadI->getType(), pred_size(LoadBB), "");
PN->insertBefore(LoadBB->begin());
PN->takeName(LoadI);
PN->setDebugLoc(LoadI->getDebugLoc());
// Insert new entries into the PHI for each predecessor. A single block may
// have multiple entries here.
for (pred_iterator PI = PB; PI != PE; ++PI) {
BasicBlock *P = *PI;
for (BasicBlock *P : predecessors(LoadBB)) {
AvailablePredsTy::iterator I =
llvm::lower_bound(AvailablePreds, std::make_pair(P, (Value *)nullptr));