diff options
author | Dan Gohman <gohman@apple.com> | 2009-06-22 03:18:45 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-06-22 03:18:45 +0000 |
commit | f9a9a9928cc977970d9852292b1c139074ecf055 (patch) | |
tree | 33a5dba878bf020c2cb74aed81f275e18e466125 /lib | |
parent | 2cf5f14f20ef0dc0d1ebddc45e11661df91f6ebf (diff) | |
download | external_llvm-f9a9a9928cc977970d9852292b1c139074ecf055.zip external_llvm-f9a9a9928cc977970d9852292b1c139074ecf055.tar.gz external_llvm-f9a9a9928cc977970d9852292b1c139074ecf055.tar.bz2 |
Factor out code for computing umin and smin for SCEV expressions into
helper functions. Based on a patch by Nick Lewycky.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73869 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/ScalarEvolution.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/Analysis/ScalarEvolution.cpp b/lib/Analysis/ScalarEvolution.cpp index d851913..68aa595 100644 --- a/lib/Analysis/ScalarEvolution.cpp +++ b/lib/Analysis/ScalarEvolution.cpp @@ -1903,6 +1903,18 @@ ScalarEvolution::getUMaxExpr(SmallVectorImpl<SCEVHandle> &Ops) { return Result; } +SCEVHandle ScalarEvolution::getSMinExpr(const SCEVHandle &LHS, + const SCEVHandle &RHS) { + // ~smax(~x, ~y) == smin(x, y). + return getNotSCEV(getSMaxExpr(getNotSCEV(LHS), getNotSCEV(RHS))); +} + +SCEVHandle ScalarEvolution::getUMinExpr(const SCEVHandle &LHS, + const SCEVHandle &RHS) { + // ~umax(~x, ~y) == umin(x, y) + return getNotSCEV(getUMaxExpr(getNotSCEV(LHS), getNotSCEV(RHS))); +} + SCEVHandle ScalarEvolution::getUnknown(Value *V) { if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) return getConstant(CI); @@ -2644,10 +2656,7 @@ SCEVHandle ScalarEvolution::createSCEV(Value *V) { if (LHS == U->getOperand(1) && RHS == U->getOperand(2)) return getSMaxExpr(getSCEV(LHS), getSCEV(RHS)); else if (LHS == U->getOperand(2) && RHS == U->getOperand(1)) - // ~smax(~x, ~y) == smin(x, y). - return getNotSCEV(getSMaxExpr( - getNotSCEV(getSCEV(LHS)), - getNotSCEV(getSCEV(RHS)))); + return getSMinExpr(getSCEV(LHS), getSCEV(RHS)); break; case ICmpInst::ICMP_ULT: case ICmpInst::ICMP_ULE: @@ -2658,9 +2667,7 @@ SCEVHandle ScalarEvolution::createSCEV(Value *V) { if (LHS == U->getOperand(1) && RHS == U->getOperand(2)) return getUMaxExpr(getSCEV(LHS), getSCEV(RHS)); else if (LHS == U->getOperand(2) && RHS == U->getOperand(1)) - // ~umax(~x, ~y) == umin(x, y) - return getNotSCEV(getUMaxExpr(getNotSCEV(getSCEV(LHS)), - getNotSCEV(getSCEV(RHS)))); + return getUMinExpr(getSCEV(LHS), getSCEV(RHS)); break; case ICmpInst::ICMP_NE: // n != 0 ? n : 1 -> umax(n, 1) |