summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
diff options
context:
space:
mode:
authorHiroshi Inoue <inouehrs@jp.ibm.com>2018-06-05 11:58:01 +0000
committerHiroshi Inoue <inouehrs@jp.ibm.com>2018-06-05 11:58:01 +0000
commit955655f558f71de237732fe3f034e44373aed78a (patch)
tree937eeabb9e5541d099f8637a13733b0ab16e67df /llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
parent613fea20dc6da325a2e28d1342d1373e5b746b02 (diff)
downloadbcm5719-llvm-955655f558f71de237732fe3f034e44373aed78a.tar.gz
bcm5719-llvm-955655f558f71de237732fe3f034e44373aed78a.zip
[PowerPC] reduce rotate in BitPermutationSelector
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. Differential Revision: https://reviews.llvm.org/D47765 llvm-svn: 334011
Diffstat (limited to 'llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp')
-rw-r--r--llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
index a0f12ecd9d7..333a880509c 100644
--- a/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
+++ b/llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp
@@ -1161,6 +1161,10 @@ class BitPermutationSelector {
return true;
else if (NumGroups < Other.NumGroups)
return false;
+ else if (RLAmt == 0 && Other.RLAmt != 0)
+ return true;
+ else if (RLAmt != 0 && Other.RLAmt == 0)
+ return false;
else if (FirstGroupStartIdx < Other.FirstGroupStartIdx)
return true;
return false;
@@ -1374,7 +1378,9 @@ class BitPermutationSelector {
}
// Take all (SDValue, RLAmt) pairs and sort them by the number of groups
- // associated with each. If there is a degeneracy, pick the one that occurs
+ // associated with each. If the number of groups are same, we prefer a group
+ // which does not require rotate, i.e. RLAmt is 0, to avoid the first rotate
+ // instruction. If there is a degeneracy, pick the one that occurs
// first (in the final value).
void collectValueRotInfo() {
ValueRots.clear();
OpenPOWER on IntegriCloud