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
Event Timeline
Comment Actions
LGTM
| lib/Analysis/ScalarEvolution.cpp | ||
|---|---|---|
| 3149–3160 | 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 | Add a short comment that subtract does not preserve nsw/nuw Flags. | |
Flags doesn't seem very useful now, perhaps it should be removed?