}
// Return zero if truncating to known zeros.
- uint32_t MinTrailingZeros = GetMinTrailingZeros(Op);
+ uint32_t MinTrailingZeros = getMinTrailingZeros(Op);
if (MinTrailingZeros >= getTypeSizeInBits(Ty))
return getZero(Ty);
// Find number of trailing zeros of (x + y + ...) w/o the C first:
uint32_t TZ = BitWidth;
for (unsigned I = 1, E = WholeAddExpr->getNumOperands(); I < E && TZ; ++I)
- TZ = std::min(TZ, SE.GetMinTrailingZeros(WholeAddExpr->getOperand(I)));
+ TZ = std::min(TZ, SE.getMinTrailingZeros(WholeAddExpr->getOperand(I)));
if (TZ) {
// Set D to be as many least significant bits of C as possible while still
// guaranteeing that adding D to (C - D + x + y + ...) won't cause a wrap:
const APInt &ConstantStart,
const SCEV *Step) {
const unsigned BitWidth = ConstantStart.getBitWidth();
- const uint32_t TZ = SE.GetMinTrailingZeros(Step);
+ const uint32_t TZ = SE.getMinTrailingZeros(Step);
if (TZ)
return TZ < BitWidth ? ConstantStart.trunc(TZ).zext(BitWidth)
: ConstantStart;
return getGEPExpr(GEP, IndexExprs);
}
-uint32_t ScalarEvolution::GetMinTrailingZerosImpl(const SCEV *S) {
+uint32_t ScalarEvolution::getMinTrailingZerosImpl(const SCEV *S) {
switch (S->getSCEVType()) {
case scConstant:
return cast<SCEVConstant>(S)->getAPInt().countr_zero();
- case scVScale:
- return 0;
case scTruncate: {
const SCEVTruncateExpr *T = cast<SCEVTruncateExpr>(S);
- return std::min(GetMinTrailingZeros(T->getOperand()),
+ return std::min(getMinTrailingZeros(T->getOperand()),
(uint32_t)getTypeSizeInBits(T->getType()));
}
- case scZeroExtend: {
- const SCEVZeroExtendExpr *E = cast<SCEVZeroExtendExpr>(S);
- uint32_t OpRes = GetMinTrailingZeros(E->getOperand());
- return OpRes == getTypeSizeInBits(E->getOperand()->getType())
- ? getTypeSizeInBits(E->getType())
- : OpRes;
- }
+ case scZeroExtend:
case scSignExtend: {
- const SCEVSignExtendExpr *E = cast<SCEVSignExtendExpr>(S);
- uint32_t OpRes = GetMinTrailingZeros(E->getOperand());
+ const SCEVIntegralCastExpr *E = cast<SCEVIntegralCastExpr>(S);
+ uint32_t OpRes = getMinTrailingZeros(E->getOperand());
return OpRes == getTypeSizeInBits(E->getOperand()->getType())
? getTypeSizeInBits(E->getType())
: OpRes;
case scMulExpr: {
const SCEVMulExpr *M = cast<SCEVMulExpr>(S);
// The result is the sum of all operands results.
- uint32_t SumOpRes = GetMinTrailingZeros(M->getOperand(0));
+ uint32_t SumOpRes = getMinTrailingZeros(M->getOperand(0));
uint32_t BitWidth = getTypeSizeInBits(M->getType());
- for (unsigned i = 1, e = M->getNumOperands();
- SumOpRes != BitWidth && i != e; ++i)
+ for (unsigned I = 1, E = M->getNumOperands();
+ SumOpRes != BitWidth && I != E; ++I)
SumOpRes =
- std::min(SumOpRes + GetMinTrailingZeros(M->getOperand(i)), BitWidth);
+ std::min(SumOpRes + getMinTrailingZeros(M->getOperand(I)), BitWidth);
return SumOpRes;
}
+ case scVScale:
+ return 0;
case scUDivExpr:
return 0;
case scPtrToInt:
case scSequentialUMinExpr: {
// The result is the min of all operands results.
ArrayRef<const SCEV *> Ops = S->operands();
- uint32_t MinOpRes = GetMinTrailingZeros(Ops[0]);
+ uint32_t MinOpRes = getMinTrailingZeros(Ops[0]);
for (unsigned I = 1, E = Ops.size(); MinOpRes && I != E; ++I)
- MinOpRes = std::min(MinOpRes, GetMinTrailingZeros(Ops[I]));
+ MinOpRes = std::min(MinOpRes, getMinTrailingZeros(Ops[I]));
return MinOpRes;
}
case scUnknown: {
llvm_unreachable("Unknown SCEV kind!");
}
-uint32_t ScalarEvolution::GetMinTrailingZeros(const SCEV *S) {
+uint32_t ScalarEvolution::getMinTrailingZeros(const SCEV *S) {
auto I = MinTrailingZerosCache.find(S);
if (I != MinTrailingZerosCache.end())
return I->second;
- uint32_t Result = GetMinTrailingZerosImpl(S);
+ uint32_t Result = getMinTrailingZerosImpl(S);
auto InsertPair = MinTrailingZerosCache.insert({S, Result});
assert(InsertPair.second && "Should insert a new key");
return InsertPair.first->second;
// If the value has known zeros, the maximum value will have those known zeros
// as well.
- uint32_t TZ = GetMinTrailingZeros(S);
+ uint32_t TZ = getMinTrailingZeros(S);
if (TZ != 0) {
if (SignHint == ScalarEvolution::HINT_RANGE_UNSIGNED)
ConservativeResult =
if (!TC)
// Attempt to factor more general cases. Returns the greatest power of
// two divisor.
- return GetSmallMultiple(GetMinTrailingZeros(TCExpr));
+ return GetSmallMultiple(getMinTrailingZeros(TCExpr));
ConstantInt *Result = TC->getValue();
assert(Result && "SCEVConstant expected to have non-null ConstantInt");
//
// B is divisible by D if and only if the multiplicity of prime factor 2 for B
// is not less than multiplicity of this prime factor for D.
- if (SE.GetMinTrailingZeros(B) < Mult2)
+ if (SE.getMinTrailingZeros(B) < Mult2)
return SE.getCouldNotCompute();
// 3. Compute I: the multiplicative inverse of (A / D) in arithmetic