diff options
Diffstat (limited to 'llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp index 2f644406c0f..b3bd1f01232 100644 --- a/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp +++ b/llvm/lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp @@ -930,10 +930,10 @@ void LoopConstrainer::cloneLoop(LoopConstrainer::ClonedLoop &Result, continue; // not an exit block for (Instruction &I : *SBB) { - if (!isa<PHINode>(&I)) + auto *PN = dyn_cast<PHINode>(&I); + if (!PN) break; - PHINode *PN = cast<PHINode>(&I); Value *OldIncoming = PN->getIncomingValueForBlock(OriginalBB); PN->addIncoming(GetClonedValue(OldIncoming), ClonedBB); } @@ -1066,11 +1066,10 @@ LoopConstrainer::RewrittenRangeInfo LoopConstrainer::changeIterationSpaceEnd( // each of the PHI nodes in the loop header. This feeds into the initial // value of the same PHI nodes if/when we continue execution. for (Instruction &I : *LS.Header) { - if (!isa<PHINode>(&I)) + auto *PN = dyn_cast<PHINode>(&I); + if (!PN) break; - PHINode *PN = cast<PHINode>(&I); - PHINode *NewPHI = PHINode::Create(PN->getType(), 2, PN->getName() + ".copy", BranchToContinuation); @@ -1103,11 +1102,10 @@ void LoopConstrainer::rewriteIncomingValuesForPHIs( unsigned PHIIndex = 0; for (Instruction &I : *LS.Header) { - if (!isa<PHINode>(&I)) + auto *PN = dyn_cast<PHINode>(&I); + if (!PN) break; - PHINode *PN = cast<PHINode>(&I); - for (unsigned i = 0, e = PN->getNumIncomingValues(); i < e; ++i) if (PN->getIncomingBlock(i) == ContinuationBlock) PN->setIncomingValue(i, RRI.PHIValuesAtPseudoExit[PHIIndex++]); @@ -1124,10 +1122,10 @@ BasicBlock *LoopConstrainer::createPreheader(const LoopStructure &LS, BranchInst::Create(LS.Header, Preheader); for (Instruction &I : *LS.Header) { - if (!isa<PHINode>(&I)) + auto *PN = dyn_cast<PHINode>(&I); + if (!PN) break; - PHINode *PN = cast<PHINode>(&I); for (unsigned i = 0, e = PN->getNumIncomingValues(); i < e; ++i) replacePHIBlock(PN, OldPreheader, Preheader); } |