SCEV: missing null check fix for r132360, dragonegg crash.
authorAndrew Trick <atrick@apple.com>
Wed, 1 Jun 2011 19:14:56 +0000 (19:14 +0000)
committerAndrew Trick <atrick@apple.com>
Wed, 1 Jun 2011 19:14:56 +0000 (19:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132416 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/ScalarEvolution.cpp

index ef390c5a3ee9012ae471be637a8e8b9d86cf5b46..025718e09febeb32cbcf0fa28122136194c9b555 100644 (file)
@@ -1081,9 +1081,8 @@ static const SCEV *getPreStartForSignExtend(const SCEVAddRecExpr *AR,
   const SCEVAddRecExpr *PreAR = dyn_cast<SCEVAddRecExpr>(
     SE->getAddRecExpr(PreStart, Step, L, SCEV::FlagAnyWrap));
 
-  if (PreAR && PreAR->getNoWrapFlags(SCEV::FlagNSW)) {
+  if (PreAR && PreAR->getNoWrapFlags(SCEV::FlagNSW))
     return PreStart;
-  }
 
   // 2. Direct overflow check on the step operation's expression.
   unsigned BitWidth = SE->getTypeSizeInBits(AR->getType());
@@ -1104,7 +1103,8 @@ static const SCEV *getPreStartForSignExtend(const SCEVAddRecExpr *AR,
   ICmpInst::Predicate Pred;
   const SCEV *OverflowLimit = getOverflowLimitForStep(Step, &Pred, SE);
 
-  if (SE->isLoopEntryGuardedByCond(L, Pred, PreStart, OverflowLimit)) {
+  if (OverflowLimit &&
+      SE->isLoopEntryGuardedByCond(L, Pred, PreStart, OverflowLimit)) {
     return PreStart;
   }
   return 0;