// Do not reason about pointers where the index size is larger than 64 bits,
// as the coefficients used to encode constraints are 64 bit integers.
if (DL.getIndexTypeSizeInBits(GEP.getPointerOperand()->getType()) > 64)
- return {};
+ return {{0, nullptr}, {1, &GEP}};
if (!GEP.isInBounds())
return {{0, nullptr}, {1, &GEP}};
auto GTI = gep_type_begin(GEP);
// Bail out for scalable vectors for now.
if (isa<ScalableVectorType>(GTI.getIndexedType()))
- return {};
+ return {{0, nullptr}, {1, &GEP}};
int64_t Scale = static_cast<int64_t>(
DL.getTypeAllocSize(GTI.getIndexedType()).getFixedSize());
// Bail out for scalable vectors for now.
if (isa<ScalableVectorType>(GTI.getIndexedType()))
- return {};
+ return {{0, nullptr}, {1, &GEP}};
// Struct indices must be constants (and reference an existing field). Add
// them to the constant factor.
unsigned Scale = DL.getTypeAllocSize(GTI.getIndexedType()).getFixedSize();
auto IdxResult = decompose(Index, Preconditions, IsSigned, DL);
- if (IdxResult.empty()) {
- Result.emplace_back(Scale, Index);
- } else {
- for (auto &KV : IdxResult)
- KV.Coefficient = multiplyWithOverflow(KV.Coefficient, Scale);
- Result[0].Coefficient += IdxResult[0].Coefficient;
- append_range(Result, ArrayRef<DecompEntry>(IdxResult).drop_front());
- }
+ for (auto &KV : IdxResult)
+ KV.Coefficient = multiplyWithOverflow(KV.Coefficient, Scale);
+ Result[0].Coefficient += IdxResult[0].Coefficient;
+ append_range(Result, ArrayRef<DecompEntry>(IdxResult).drop_front());
+
// If Op0 is signed non-negative, the GEP is increasing monotonically and
// can be de-composed.
if (!isKnownNonNegative(Index, DL, /*Depth=*/MaxAnalysisRecursionDepth - 1))
bool IsSignedB) -> SmallVector<DecompEntry, 4> {
auto ResA = decompose(A, Preconditions, IsSigned, DL);
auto ResB = decompose(B, Preconditions, IsSignedB, DL);
- if (ResA.empty() || ResB.empty())
- return {};
ResA[0].Coefficient += ResB[0].Coefficient;
append_range(ResA, drop_begin(ResB));
return ResA;
if (auto *CI = dyn_cast<ConstantInt>(V)) {
if (CI->uge(MaxConstraintValue))
- return {};
+ return {{0, nullptr}, {1, V}};
return {{int64_t(CI->getZExtValue()), nullptr}};
}
Preconditions, IsSigned, DL);
auto BDec = decompose(Op1->stripPointerCastsSameRepresentation(),
Preconditions, IsSigned, DL);
- // Skip if decomposing either of the values failed.
- if (ADec.empty() || BDec.empty())
- return {};
-
int64_t Offset1 = ADec[0].Coefficient;
int64_t Offset2 = BDec[0].Coefficient;
Offset1 *= -1;