diff options
Diffstat (limited to 'lib/Analysis')
| -rw-r--r-- | lib/Analysis/ScalarEvolutionExpander.cpp | 9 | 
1 files changed, 6 insertions, 3 deletions
| diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 59f19a002ecc..7e9e35127a49 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -1776,9 +1776,12 @@ unsigned SCEVExpander::replaceCongruentIVs(Loop *L, const DominatorTree *DT,                          << *IsomorphicInc << '\n');          Value *NewInc = OrigInc;          if (OrigInc->getType() != IsomorphicInc->getType()) { -          Instruction *IP = isa<PHINode>(OrigInc) -            ? (Instruction*)L->getHeader()->getFirstInsertionPt() -            : OrigInc->getNextNode(); +          Instruction *IP = nullptr; +          if (PHINode *PN = dyn_cast<PHINode>(OrigInc)) +            IP = PN->getParent()->getFirstInsertionPt(); +          else +            IP = OrigInc->getNextNode(); +            IRBuilder<> Builder(IP);            Builder.SetCurrentDebugLocation(IsomorphicInc->getDebugLoc());            NewInc = Builder. | 
