Page MenuHomePhabricator

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

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



In isel, transform

Num % Den


Num - (Num / Den) * Den

if the result of Num / Den is already available.

Diff Detail


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.


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.