Adds a function that checks whether one SCEV provably divides by other without
remainder if both values are treated as signed. No usage of the function comes
with this patch.
Details
Diff Detail
Event Timeline
Going to add some stuff to make clear distinction between signed and unsigned division.
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
8963 | Not really. We can operate with negative values, for example of S = 0 or S = Divisor or Divisor = 1. I also think that it will be OK to return true for Divisor = -1 and S = -Divisor, and this is not be true in unsigned division. I am going to add these cases. | |
8973 | This is only needed to work with negative values in some particular cases. getURemExpr interprets all as positive. I want isDivisorOf(-5, 5) be true, but (UINT_MAX - 4) urem 5 = 1. |
Hi Max,
Do you mind giving an overview of how you're going to use this?
include/llvm/Analysis/ScalarEvolution.h | ||
---|---|---|
685 | s/provably divides/provably signed divides/ |
The general idea is that I plan to factor out concept of SCEV range (which is basically a tripple Begin, End, Step) into an utility class. The concept of such range is used in IRCE, Loop Predication and some other passes, each of them has its own implementation of basic stuff (such as intersection, contains check etc).
As one of pieces of this work, I want to implement intersection of ranges with step different from 1. At least we can handle simple cases: for example intersection of range Begin = 0, End = 100, Step = 5 and range Begin = 0, End = 100, Step = 10 is Begin = 0, End = 100, Step = 10.
This particular function (and its unsigned analogue) will be used like following: given 2 ranges with steps S1 and S2, and S1 divides by S2, and both Begin1, Begin2 have the same remainder mod S1, then their intersection is a range with Begin = max(Begin1, Begin2) and Step = S1.
I'm ok with this patch to not be merged until its application is implemented.
s/provably divides/provably signed divides/