We already support pulling through an add with constant RHS. We can do the same for subtract.
Details
Diff Detail
Event Timeline
For reference, http://rise4fun.com/Alive/8l5 .
This transform throws nsw/nuw flags; can we preserve them in some situations?
| lib/Transforms/InstCombine/InstCombineShifts.cpp | ||
|---|---|---|
| 525 | Maybe add a comment writing out the transform in mathematical terms? (e.g. "2 * (A - B)" -> "2 * A - 2 * B"). | |
| test/Transforms/InstCombine/sub.ll | ||
| 1082 | This could use a couple more tests, to specifically show the transform this patch adds. | |
Add a simpler test case and a more mathematical comment.
Not sure how to preserve NSW/NUW without calling computeKnownBits. Any ideas?
LGTM, with one small question.
| lib/Transforms/InstCombine/InstCombineShifts.cpp | ||
|---|---|---|
| 518 | It looks like this can match a vector? If it can, please add a vector testcase. | |
It looks like this can match a vector? If it can, please add a vector testcase.