When LSR processes code like
int accumulator = 0; for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) accumulator += i * j; use((double) sum); }
It may decide to replace integer accumulator with a double Shadow IV to get rid
of casts. The problem with that is that the accumulator's value may overflow.
Starting from this moment, the behavior of integer and double accumulators
will differ.
This patch strenghtens up the conditions of Shadow IV mechanism applicability.
We only allow it for IVs that are proved to be AddRecs with nw flag.
I don't think this is the correct check. Specifically, this check allows overflow as long as we can guarantee that the value never reaches it's starting value. I think you actually want hasNoUnsignedWrap() && hasNoSignedWrap()
Consider:
unsigned i = 1
do {
} while ( (signed int)i > 0)