mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-02 07:11:49 +00:00
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
This commit is contained in:
parent
2cf5f14f20
commit
f9a9a9928c
@ -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