This is an archive of the discontinued LLVM Phabricator instance.

[InstCombine] fold X urem C -> X < C ? X : X - C when C is big (PR28672)
ClosedPublic

Authored by spatel on Sep 13 2016, 4:08 PM.

Details

Summary

We already have the udiv variant of this transform, so I think this is ok for InstCombine too even though there is an increase in IR instructions. As the tests and TODO comments show, the transform can lead to follow-on combines.

https://llvm.org/bugs/show_bug.cgi?id=28672

Diff Detail

Repository
rL LLVM

Event Timeline

spatel updated this revision to Diff 71252.Sep 13 2016, 4:08 PM
spatel retitled this revision from to [InstCombine] fold X urem C -> X < C ? X : X - C when C is big (PR28672).
spatel updated this object.
spatel added reviewers: sanjoy, efriedma, majnemer.
spatel added a subscriber: llvm-commits.
efriedma accepted this revision.Sep 21 2016, 4:14 PM
efriedma edited edge metadata.

Looks fine to me. It makes sense to prefer select as the canonical form.

This revision is now accepted and ready to land.Sep 21 2016, 4:14 PM

Thanks, Eli!

This revision was automatically updated to reflect the committed changes.