APInt AccConstIndices(BitWidth, 0, /*IsSigned*/ true);
gep_type_iterator GTI = gep_type_begin(I);
- // If the inbounds keyword is not present, the offsets are added to the
- // base address with silently-wrapping two’s complement arithmetic.
- bool IsInBounds = cast<GEPOperator>(I)->isInBounds();
for (unsigned i = 1, e = I->getNumOperands(); i != e; ++i, ++GTI) {
// TrailZ can only become smaller, short-circuit if we hit zero.
if (Known.isUnknown())
// to the width of the pointer.
IndexBits = IndexBits.sextOrTrunc(BitWidth);
+ // Note that inbounds does *not* guarantee nsw for the addition, as only
+ // the offset is signed, while the base address is unsigned.
Known = KnownBits::computeForAddSub(
- /*Add=*/true,
- /*NSW=*/IsInBounds, Known, IndexBits);
+ /*Add=*/true, /*NSW=*/false, Known, IndexBits);
}
if (!Known.isUnknown() && !AccConstIndices.isNullValue()) {
KnownBits Index(BitWidth);
Index.Zero = ~AccConstIndices;
Index.One = AccConstIndices;
Known = KnownBits::computeForAddSub(
- /*Add=*/true,
- /*NSW=*/IsInBounds, Known, Index);
+ /*Add=*/true, /*NSW=*/false, Known, Index);
}
break;
}