Add a new pass - AssumingScalarEvolution - that extends
SCEV, but can make assumptions and generate code that
can check these assumptions. This pass uses the normal
ScalarEvolution pass for anything outside the current
analyzed loop, but uses its own data structures to handle
the SCEVs within the loop. For now, the pass assumes
that chrec expressions will not overflow.
The AssumingScalarEvolution pass can add checks for the
made assumptions, so that a loop can be versioned.
We use this pass in order to add runtime overflow checks
in the Loop Vectorize pass of expressions which can
in theory overflow and would prevent the vectorization
a loop. Also note that the runtime checks will almost always
pass, since having an overflow is usually a sign of a
coding error on the part of user.
The main reasons behind inheriting from ScalarEvolution:
Since ScalarEvolution maintains its own cache for various
results, making any assumption would likely require invalidating
the entire cache.
This way we can use the new pass as an almost drop-in
replacement for ScalarEvolution. The users that are doing
a transformation would have to know about it in order to add
the checks.
However, there are probably a lot more ways in which this could
be implemented.
Any comments are much appreciated!
Thanks,
Silviu
Can you please make this a bit more precise? E.g.
With these assumption satisfied the memory accesses become simple AddRecs which allows them to get analyzed.
Also it should either be called Preds or PredSet.