mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
Factor out code for computing umin and smin for SCEV expressions into
helper functions. Based on a patch by Nick Lewycky. llvm-svn: 73869
This commit is contained in:
parent
82084cf5a1
commit
d65752db50
@ -494,6 +494,8 @@ namespace llvm {
|
||||
SCEVHandle getSMaxExpr(SmallVectorImpl<SCEVHandle> &Operands);
|
||||
SCEVHandle getUMaxExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
||||
SCEVHandle getUMaxExpr(SmallVectorImpl<SCEVHandle> &Operands);
|
||||
SCEVHandle getSMinExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
||||
SCEVHandle getUMinExpr(const SCEVHandle &LHS, const SCEVHandle &RHS);
|
||||
SCEVHandle getUnknown(Value *V);
|
||||
SCEVHandle getCouldNotCompute();
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user