This change teaches SCEV to see reduce `(extractvalue
0 (op.with.overflow X Y)) into op X Y` (with a no-wrap tag if
possible).
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Sanjoy do you mind exposing IsResultNoOverflow() in such a way that it can be used by other passes? I was going to implement this myself (it's what I was asking about on twitter last night) but of course would rather just use yours.
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
3841 ↗ | (On Diff #52330) | I'm a little confused about this loop-- since we're looking for one branch, why do we want the loop here instead of just returning false if the CallInst has more than one user? |
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
3841 ↗ | (On Diff #52330) | We're also accumulating the result projections into AddVals (which in retrospect should be called something else, since they're not just additions -- I'll fix that). |
Address review:
- Export isOverflowIntrinsicNoWrap to ValueTracking
- Generalize the logic a bit and add more tests to demonstrate
I couldn't find a better name than isOverflowIntrinsicNoWrap that
isn't also terribly verbose. Suggestions welcome!
This looks great. It seems like it will work well for createAddRecFromPHI.
I think we're still missing intrinsic support in getNoWrapFlagsFromUB.
Looks great.
include/llvm/Analysis/ValueTracking.h | ||
---|---|---|
332 ↗ | (On Diff #53157) | would something isOverflowGuard() work better? |
include/llvm/Analysis/ValueTracking.h | ||
---|---|---|
332 ↗ | (On Diff #53157) | I'd say that would be misleading since we're not checking if the arithmetic operation can overflow, but that the "arithmetic result" projection of the intrinsic can be treated as no-wrap. So, as an example, the routine can (and will, in most cases) return true for an overflow intrinsic for which the "arithmetic result" projection is unused. |