diff options
| author | Guozhi Wei <carrot@google.com> | 2016-12-12 22:09:02 +0000 |
|---|---|---|
| committer | Guozhi Wei <carrot@google.com> | 2016-12-12 22:09:02 +0000 |
| commit | 1fd553c9345ff9f1f32b1256bae0f2d63ec3ae38 (patch) | |
| tree | bc1eee5191bd4080607547efdd097a04e8df213c /llvm/lib/Target/PowerPC | |
| parent | 44bde896a5f88f0d4e283ff4b5ab3a04df32848d (diff) | |
| download | bcm5719-llvm-1fd553c9345ff9f1f32b1256bae0f2d63ec3ae38.tar.gz bcm5719-llvm-1fd553c9345ff9f1f32b1256bae0f2d63ec3ae38.zip | |
[PPC] Prefer direct move on power8 if load 1 or 2 bytes to VSR
Power8 has MTVSRWZ but no LXSIBZX/LXSIHZX, so move 1 or 2 bytes to VSR through MTVSRWZ is much faster than store the extended value into stack and load it with LXSIWZX.
This patch fixes pr31144.
Differential Revision: https://reviews.llvm.org/D27287
llvm-svn: 289473
Diffstat (limited to 'llvm/lib/Target/PowerPC')
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/Target/PowerPC/PPCISelLowering.h | 2 |
2 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp index 75b5180a943..aa3ffde24b9 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.cpp @@ -6606,11 +6606,17 @@ void PPCTargetLowering::spliceIntoChain(SDValue ResChain, /// \brief Analyze profitability of direct move /// prefer float load to int load plus direct move /// when there is no integer use of int load -static bool directMoveIsProfitable(const SDValue &Op) { +bool PPCTargetLowering::directMoveIsProfitable(const SDValue &Op) const { SDNode *Origin = Op.getOperand(0).getNode(); if (Origin->getOpcode() != ISD::LOAD) return true; + // If there is no LXSIBZX/LXSIHZX, like Power8, + // prefer direct move if the memory size is 1 or 2 bytes. + MachineMemOperand *MMO = cast<LoadSDNode>(Origin)->getMemOperand(); + if (!Subtarget.hasP9Vector() && MMO->getSize() <= 2) + return true; + for (SDNode::use_iterator UI = Origin->use_begin(), UE = Origin->use_end(); UI != UE; ++UI) { diff --git a/llvm/lib/Target/PowerPC/PPCISelLowering.h b/llvm/lib/Target/PowerPC/PPCISelLowering.h index 95f32f5fc12..d3c88482f09 100644 --- a/llvm/lib/Target/PowerPC/PPCISelLowering.h +++ b/llvm/lib/Target/PowerPC/PPCISelLowering.h @@ -815,6 +815,8 @@ namespace llvm { SelectionDAG &DAG, const SDLoc &dl) const; SDValue LowerFP_TO_INTDirectMove(SDValue Op, SelectionDAG &DAG, const SDLoc &dl) const; + + bool directMoveIsProfitable(const SDValue &Op) const; SDValue LowerINT_TO_FPDirectMove(SDValue Op, SelectionDAG &DAG, const SDLoc &dl) const; |

