This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Compute 'rem' using the result of 'div', if possible.
ClosedPublic

Authored by jlebar on Oct 28 2016, 10:55 AM.

Details

Summary

In isel, transform

Num % Den

into

Num - (Num / Den) * Den

if the result of Num / Den is already available.

Diff Detail

Repository
rL LLVM

Event Timeline

jlebar updated this revision to Diff 76219.Oct 28 2016, 10:55 AM
jlebar retitled this revision from to [NVPTX] Compute 'rem' using the result of 'div', if possible..
jlebar updated this object.
jlebar added a reviewer: tra.
jlebar added subscribers: jholewinski, llvm-commits, hfinkel.
tra accepted this revision.Oct 28 2016, 11:21 AM
tra edited edge metadata.

Nice.

This revision is now accepted and ready to land.Oct 28 2016, 11:21 AM
This revision was automatically updated to reflect the committed changes.
joerg added a subscriber: joerg.Oct 29 2016, 1:07 PM

We've been talking about this on IRC. It would be nice to have this as target-independent option, since on many platforms a generic rem is much slower than a div followed by a multiply/subtract. Only platforms with very slow hardware multiply want to use div and rem as separate instructions.