From c54c561c9f7270c055dd7ba75a3a003b771a42d9 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sun, 25 Nov 2007 22:41:31 +0000 Subject: Add new SCEV, SCEVSMax. This allows LLVM to analyze do-while loops. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44319 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ScalarEvolutionExpander.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp') diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 3bac3024c4..88fd0aaf8f 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -208,6 +208,16 @@ Value *SCEVExpander::visitAddRecExpr(SCEVAddRecExpr *S) { return expand(V); } +Value *SCEVExpander::visitSMaxExpr(SCEVSMaxExpr *S) { + Value *LHS = expand(S->getOperand(0)); + for (unsigned i = 1; i < S->getNumOperands(); ++i) { + Value *RHS = expand(S->getOperand(i)); + Value *ICmp = new ICmpInst(ICmpInst::ICMP_SGT, LHS, RHS, "tmp", InsertPt); + LHS = new SelectInst(ICmp, LHS, RHS, "smax", InsertPt); + } + return LHS; +} + Value *SCEVExpander::expand(SCEV *S) { // Check to see if we already expanded this. std::map::iterator I = InsertedExpressions.find(S); -- cgit v1.2.3