[llvm-commits] CVS: llvm/lib/Analysis/LoopInfo.cpp

Chris Lattner lattner at cs.uiuc.edu
Tue Jun 8 16:56:01 PDT 2004


Changes in directory llvm/lib/Analysis:

LoopInfo.cpp updated: 1.55 -> 1.56

---
Log message:

Don't grab the condition of unconditional branches!
This fixes PR363: http://llvm.cs.uiuc.edu/PR363 


---
Diffs of the changes:  (+8 -7)

Index: llvm/lib/Analysis/LoopInfo.cpp
diff -u llvm/lib/Analysis/LoopInfo.cpp:1.55 llvm/lib/Analysis/LoopInfo.cpp:1.56
--- llvm/lib/Analysis/LoopInfo.cpp:1.55	Sun Apr 18 22:02:09 2004
+++ llvm/lib/Analysis/LoopInfo.cpp	Tue Jun  8 16:50:30 2004
@@ -442,14 +442,15 @@
     IV->getIncomingBlock(contains(IV->getIncomingBlock(1)));
 
   if (BranchInst *BI = dyn_cast<BranchInst>(BackedgeBlock->getTerminator()))
-    if (SetCondInst *SCI = dyn_cast<SetCondInst>(BI->getCondition()))
-      if (SCI->getOperand(0) == Inc)
-        if (BI->getSuccessor(0) == getHeader()) {
-          if (SCI->getOpcode() == Instruction::SetNE)
+    if (BI->isConditional())
+      if (SetCondInst *SCI = dyn_cast<SetCondInst>(BI->getCondition()))
+        if (SCI->getOperand(0) == Inc)
+          if (BI->getSuccessor(0) == getHeader()) {
+            if (SCI->getOpcode() == Instruction::SetNE)
+              return SCI->getOperand(1);
+          } else if (SCI->getOpcode() == Instruction::SetEQ) {
             return SCI->getOperand(1);
-        } else if (SCI->getOpcode() == Instruction::SetEQ) {
-          return SCI->getOperand(1);
-        }
+          }
   
   return 0;
 }





More information about the llvm-commits mailing list