Page MenuHomePhabricator

[InstCombine] Support pulling left shifts through a subtract with constant LHS

Authored by craig.topper on Aug 7 2017, 10:37 PM.

Diff Detail


Event Timeline

craig.topper created this revision.Aug 7 2017, 10:37 PM

Use Builder.CreateShl since we know this is a left shift.

efriedma edited edge metadata.Aug 8 2017, 11:13 AM

For reference, .

This transform throws nsw/nuw flags; can we preserve them in some situations?

525 ↗(On Diff #110137)

Maybe add a comment writing out the transform in mathematical terms? (e.g. "2 * (A - B)" -> "2 * A - 2 * B").

1082 ↗(On Diff #110137)

This could use a couple more tests, to specifically show the transform this patch adds.

zzheng added a subscriber: zzheng.Aug 8 2017, 11:45 AM

Add a simpler test case and a more mathematical comment.

Not sure how to preserve NSW/NUW without calling computeKnownBits. Any ideas?

efriedma accepted this revision.Aug 8 2017, 1:03 PM

LGTM, with one small question.

518 ↗(On Diff #110256)

It looks like this can match a vector? If it can, please add a vector testcase.

This revision is now accepted and ready to land.Aug 8 2017, 1:03 PM

Good catch. I'll add a vector test.

This revision was automatically updated to reflect the committed changes.