ScalarEvolution currently lowers a subtraction recurrence to an add recurrence with the same no-wrap flags as the subtraction. This is incorrect because sub nsw X, Y is not the same as add nsw X, -Y and sub nuw X, Y is not the same as add nuw X, -Y. This patch fixes the issue, and adds a test case demonstrating the bug.
Details
Details
Diff Detail
Diff Detail
- Repository
- rL LLVM
Event Timeline
Comment Actions
LGTM
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
3149–3160 ↗ | (On Diff #18485) | Flags doesn't seem very useful now, perhaps it should be removed? |
Comment Actions
LGTM with one suggestion for comment.
Thanks for the test cases.
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
3464–3469 ↗ | (On Diff #18485) | Add a short comment that subtract does not preserve nsw/nuw Flags. |
Comment Actions
Replies inline.
lib/Analysis/ScalarEvolution.cpp | ||
---|---|---|
3149–3160 ↗ | (On Diff #18485) | Yup, I'll do that in a follow-up refactoring change. |
3464–3469 ↗ | (On Diff #18485) | Will do. |