When creating a SCEV for X - Y infer NSW for the resulting expression if X and Y are either both non-positive or non-negative.
In these cases there can be no signed overflow.
Details
- Reviewers
mkazantsev nikic fhahn aleksandr.popov
Diff Detail
Event Timeline
I'd suspect that contextual analysis on SCEV creation might have negative CT impact.
llvm/lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
7717 | There is certain semblance b/w what you are doing and what willNotOverflow is doing. I also have an improvement for it that makes it support sub with context: D148618. I think it's a superset of (w/ this patch) of what you are trying to achieve. Will calling this function w/ right context help here? If yes, you could do it for both add and sub. I have a concern about using of context-aware checkers in SCEV creation. It might be OK since it is only done once, but I'm not sure what's the real impact on CT. Might be expensive, @nikic WDYT? | |
7728 | If both LHS and RHS have loops, you can use the one that is lower. |
There is certain semblance b/w what you are doing and what willNotOverflow is doing. I also have an improvement for it that makes it support sub with context: D148618. I think it's a superset of (w/ this patch) of what you are trying to achieve.
Will calling this function w/ right context help here? If yes, you could do it for both add and sub.
I have a concern about using of context-aware checkers in SCEV creation. It might be OK since it is only done once, but I'm not sure what's the real impact on CT. Might be expensive, @nikic WDYT?