On Feb 9, 2008, at 10:06 AM, Wojciech Matyjewicz wrote: > 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).
Nice. This method is pretty large, and it is specific to the LLVM IR loop info (not machine loop info etc). Would it be possible to make it an out of line method in LoopInfo that isn't in the template? -Chris > > 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; > } > > > _______________________________________________ > llvm-commits mailing list > llvm-commits@cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits