From 67fa0521b6c5033bf11f1b22f81bbf76daabb9ea Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 29 Jan 2008 02:20:41 +0000 Subject: Filter loops that subtract induction variables. These loops are not yet handled. Fix PR 1912. llvm-svn: 46484 --- llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | 34 +++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'llvm/lib/Transforms') diff --git a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp index 6698d67f91e..d31a589a78e 100644 --- a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -301,23 +301,23 @@ void LoopIndexSplit::findIndVar(Value *V, Loop *L) { Value *Op0 = I->getOperand(0); Value *Op1 = I->getOperand(1); - if (PHINode *PN = dyn_cast(Op0)) { - if (PN->getParent() == L->getHeader() - && isa(Op1)) { - IndVar = PN; - IndVarIncrement = I; - return; - } - } - - if (PHINode *PN = dyn_cast(Op1)) { - if (PN->getParent() == L->getHeader() - && isa(Op0)) { - IndVar = PN; - IndVarIncrement = I; - return; - } - } + if (PHINode *PN = dyn_cast(Op0)) + if (PN->getParent() == L->getHeader()) + if (ConstantInt *CI = dyn_cast(Op1)) + if (CI->isOne()) { + IndVar = PN; + IndVarIncrement = I; + return; + } + + if (PHINode *PN = dyn_cast(Op1)) + if (PN->getParent() == L->getHeader()) + if (ConstantInt *CI = dyn_cast(Op0)) + if (CI->isOne()) { + IndVar = PN; + IndVarIncrement = I; + return; + } return; } -- cgit v1.2.3