diff options
| author | Wojciech Matyjewicz <wmatyjewicz@fastmail.fm> | 2008-02-09 18:06:58 +0000 |
|---|---|---|
| committer | Wojciech Matyjewicz <wmatyjewicz@fastmail.fm> | 2008-02-09 18:06:58 +0000 |
| commit | 5c252865dec5d2d88582a83c997b88471105dc64 (patch) | |
| tree | 3c1dedea1c427e18b720c40a2d94f012ca674f20 | |
| parent | 4cc387212af2b39fb64d5c83aab9e34e195f38fc (diff) | |
| download | bcm5719-llvm-5c252865dec5d2d88582a83c997b88471105dc64.tar.gz bcm5719-llvm-5c252865dec5d2d88582a83c997b88471105dc64.zip | |
Add a check if the initial value of the induction variable is 0 (the method comment says it should be).
llvm-svn: 46907
| -rw-r--r-- | llvm/include/llvm/Analysis/LoopInfo.h | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/llvm/include/llvm/Analysis/LoopInfo.h b/llvm/include/llvm/Analysis/LoopInfo.h index 93c36e47d8b..4cb03fbd8e7 100644 --- a/llvm/include/llvm/Analysis/LoopInfo.h +++ b/llvm/include/llvm/Analysis/LoopInfo.h @@ -360,12 +360,16 @@ public: // 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; } |

