[llvm-commits] [llvm] r46907 - /llvm/trunk/include/llvm/Analysis/LoopInfo.h

Wojciech Matyjewicz wmatyjewicz at fastmail.fm
Sat Feb 9 10:06:58 PST 2008


Author: wmat
Date: Sat Feb  9 12:06:58 2008
New Revision: 46907

URL: http://llvm.org/viewvc/llvm-project?rev=46907&view=rev
Log:
Add a check if the initial value of the induction variable is 0 (the method comment says it should be).

Modified:
    llvm/trunk/include/llvm/Analysis/LoopInfo.h

Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=46907&r1=46906&r2=46907&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Sat Feb  9 12:06:58 2008
@@ -360,12 +360,16 @@
     // Loop over all of the PHI nodes, looking for a canonical indvar.
     for (typename BlockT::iterator I = H->begin(); isa<PHINode>(I); ++I) {
       PHINode *PN = cast<PHINode>(I);
-      if (Instruction *Inc =
-          dyn_cast<Instruction>(PN->getIncomingValueForBlock(Backedge)))
-        if (Inc->getOpcode() == Instruction::Add && Inc->getOperand(0) == PN)
-          if (ConstantInt *CI = dyn_cast<ConstantInt>(Inc->getOperand(1)))
-            if (CI->equalsInt(1))
-              return PN;
+      if (ConstantInt *CI =
+          dyn_cast<ConstantInt>(PN->getIncomingValueForBlock(Incoming)))
+        if (CI->isNullValue())
+          if (Instruction *Inc =
+              dyn_cast<Instruction>(PN->getIncomingValueForBlock(Backedge)))
+            if (Inc->getOpcode() == Instruction::Add &&
+                Inc->getOperand(0) == PN)
+              if (ConstantInt *CI = dyn_cast<ConstantInt>(Inc->getOperand(1)))
+                if (CI->equalsInt(1))
+                  return PN;
     }
     return 0;
   }





More information about the llvm-commits mailing list