diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-02-20 06:48:22 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-02-20 06:48:22 +0000 |
commit | 3e6307698084e7adfc10b739442ae29742beefd0 (patch) | |
tree | ebc561431001a1c949d932f9f8224b4ed7391ee9 /lib/Analysis/ScalarEvolutionExpander.cpp | |
parent | 19fc1d3742ccba2d8dde5d69c5593e1a0b83fefa (diff) |
Add 'umax' similar to 'smax' SCEV. Closes PR2003.
Parse reversed smax and umax as smin and umin and express them with negative
or binary-not SCEVs (which are really just subtract under the hood).
Parse 'xor %x, -1' as (-1 - %x).
Remove dead code (ConstantInt::get always returns a ConstantInt).
Don't use getIntegerSCEV(-1, Ty). The first value is an int, then it gets
passed into a uint64_t. Instead, create the -1 directly from
ConstantInt::getAllOnesValue().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47360 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/ScalarEvolutionExpander.cpp')
-rw-r--r-- | lib/Analysis/ScalarEvolutionExpander.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/Analysis/ScalarEvolutionExpander.cpp b/lib/Analysis/ScalarEvolutionExpander.cpp index 3e05600bed..0a0327d925 100644 --- a/lib/Analysis/ScalarEvolutionExpander.cpp +++ b/lib/Analysis/ScalarEvolutionExpander.cpp @@ -220,6 +220,16 @@ Value *SCEVExpander::visitSMaxExpr(SCEVSMaxExpr *S) { return LHS; } +Value *SCEVExpander::visitUMaxExpr(SCEVUMaxExpr *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_UGT, LHS, RHS, "tmp", InsertPt); + LHS = new SelectInst(ICmp, LHS, RHS, "umax", InsertPt); + } + return LHS; +} + Value *SCEVExpander::expand(SCEV *S) { // Check to see if we already expanded this. std::map<SCEVHandle, Value*>::iterator I = InsertedExpressions.find(S); @@ -230,4 +240,3 @@ Value *SCEVExpander::expand(SCEV *S) { InsertedExpressions[S] = V; return V; } - |