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)