[PATCH] D39954: [IRCE] Smart range intersection
Max Kazantsev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Nov 14 19:07:46 PST 2017
mkazantsev added inline comments.
================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:1624
//
// 0 <= M + 1 * IndVar < L given L >= 0 (i.e. N == 1)
//
----------------
anna wrote:
> Could you please state here what exactly L stands for?
Here L denotes right border of the safe iteration space of the given range check. If there is no such border (e.g. the check was `iv > low`), it is in fact `SINT_MAX + 1`, but we strengthen it to `SINT_MAX`.
================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:1658
+ "We can only substract from values in [0; SINT_MAX]!");
+ if (IsLatchSigned) {
+ // X is a number from signed range, Y is interpreted as signed.
----------------
anna wrote:
> To clarify: In both cases - signed and unsigned latch, the SCEV subtraction and rules you have below will always give us a value in range [0, SINT_MAX], i.e. we will never cross the signed border.
> Here we are just "strengthening" the range and using unambiguous values for range intersection later on IRCE.
It is not true. If we substract `-5` from `SINT_MAX` in unsigned case, we have a value greater than `SINT_MAX`.
================
Comment at: lib/Transforms/Scalar/InductiveRangeCheckElimination.cpp:1665
+ // If 0 <= -Y <= (SINT_MAX - X), we substract Y safely.
+ // Rule 2: Y >=s (X - SINT_MA) ---> Y.
+ // If 0 <= (SINT_MAX - X) < -Y, we can only substract (X - SINT).
----------------
anna wrote:
> SINT_MAX
Will fix.
https://reviews.llvm.org/D39954
More information about the llvm-commits
mailing list