This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] reduce rotate in BitPermutationSelector
ClosedPublic

Authored by inouehrs on Jun 5 2018, 2:04 AM.

Details

Summary

BitPermutationSelector builds the output value by repeating rotate-and-mask instructions with input registers.
Here, we may avoid one rotate instruction if we start building from an input register that does not require rotation.

For example of the test case bitfieldinsert.ll, it first rotates left r4 by 8 bits and then inserts some bits from r5 without rotation.
This can be executed by one rlwimi instruction, which rotates r4 by 8 bits and inserts its bits into r5.

This patch adds a check for rotation amounts in the comparator used in sorting to process the input without rotation first.

without this patch

rlwinm 4, 4, 8, 0, 31
rlwimi 4, 5, 0, 24, 7
stw 4, 0(3)

with this patch

rlwimi 5, 4, 8, 8, 23
stw 5, 0(3)

Diff Detail

Event Timeline

inouehrs created this revision.Jun 5 2018, 2:04 AM
hfinkel accepted this revision.Jun 5 2018, 2:10 AM

LGTM

This revision is now accepted and ready to land.Jun 5 2018, 2:10 AM
This revision was automatically updated to reflect the committed changes.