[PATCH] D12765: [LV] Allow vectorization of loops with induction post-inc expressions
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 17 17:12:35 PDT 2015
Hi Mikhail,
[+CC Igor -- he implemented `findExistingExpansion`]
I agree with the overall direction of the change you've proposed.
`findExistingExpansion` was designed exactly for use cases like these.
> My concern here is that while A==B isn't equivalent to
> getMinusSCEV(A,B)==Zero due to possible overflows (or is it?)
Overflow or no overflow, you can always add the same value on both
sides of an *equality* in modulo arithmetic (with inequalities like
`slt` there are problems around overflow).
To be more concrete:
If you have, as machine integers, getMinusSCEV(A,B) = Zero, then in
normal unbounded integer arithmetic (`rem` is the remainder operation,
`N` is is 2^BitWidth, and k, l are integers), you have:
(A + (((-1) * B) `rem` N)) `rem` N == 0
<=> A + (((-1) * B) `rem` N) == kN
<=> (((-1) * B) `rem` N) == kN - A
<=> ((-1) * B) == lN + kN - A
<=> B == A - (l + k) * N
And, going back to machine (wrapping) arithmetic
<=> A == B
-- Sanjoy
More information about the llvm-commits
mailing list