// The GEP index scale ("Scale") scales C1*V+C2, yielding (C1*V+C2)*Scale.
// This gives us an aggregate computation of (C1*Scale)*V + C2*Scale.
-
- // It can be the case that, even through C1*V+C2 does not overflow for
- // relevant values of V, (C2*Scale) can overflow. In that case, we cannot
- // decompose the expression in this way.
- //
- // FIXME: C1*Scale and the other operations in the decomposed
- // (C1*Scale)*V+C2*Scale can also overflow. We should check for this
- // possibility.
- bool Overflow;
- APInt ScaledOffset = LE.Offset.sextOrTrunc(MaxPointerSize)
- .smul_ov(Scale, Overflow);
- if (Overflow) {
- LE = LinearExpression(CastedValue(Index, 0, SExtBits, TruncBits));
- } else {
- Decomposed.Offset += ScaledOffset;
- Scale *= LE.Scale.sextOrTrunc(MaxPointerSize);
- }
+ Decomposed.Offset += LE.Offset.sextOrTrunc(MaxPointerSize) * Scale;
+ Scale *= LE.Scale.sextOrTrunc(MaxPointerSize);
// If we already had an occurrence of this index variable, merge this
// scale into it. For example, we want to handle: