Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 9def2dd

Browse files
committed
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289473 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 611d8de commit 9def2dd

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

lib/Target/PowerPC/PPCISelLowering.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6606,11 +6606,17 @@ void PPCTargetLowering::spliceIntoChain(SDValue ResChain,
66066606
/// \brief Analyze profitability of direct move
66076607
/// prefer float load to int load plus direct move
66086608
/// when there is no integer use of int load
6609-
static bool directMoveIsProfitable(const SDValue &Op) {
6609+
bool PPCTargetLowering::directMoveIsProfitable(const SDValue &Op) const {
66106610
SDNode *Origin = Op.getOperand(0).getNode();
66116611
if (Origin->getOpcode() != ISD::LOAD)
66126612
return true;
66136613

6614+
// If there is no LXSIBZX/LXSIHZX, like Power8,
6615+
// prefer direct move if the memory size is 1 or 2 bytes.
6616+
MachineMemOperand *MMO = cast<LoadSDNode>(Origin)->getMemOperand();
6617+
if (!Subtarget.hasP9Vector() && MMO->getSize() <= 2)
6618+
return true;
6619+
66146620
for (SDNode::use_iterator UI = Origin->use_begin(),
66156621
UE = Origin->use_end();
66166622
UI != UE; ++UI) {

lib/Target/PowerPC/PPCISelLowering.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,8 @@ namespace llvm {
815815
SelectionDAG &DAG, const SDLoc &dl) const;
816816
SDValue LowerFP_TO_INTDirectMove(SDValue Op, SelectionDAG &DAG,
817817
const SDLoc &dl) const;
818+
819+
bool directMoveIsProfitable(const SDValue &Op) const;
818820
SDValue LowerINT_TO_FPDirectMove(SDValue Op, SelectionDAG &DAG,
819821
const SDLoc &dl) const;
820822

test/CodeGen/PowerPC/pr31144.ll

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 -mattr=+vsx < %s | FileCheck %s --implicit-check-not lxsiwzx
2+
3+
declare void @bar(double)
4+
5+
define void @foo1(i8* %p) {
6+
entry:
7+
%0 = load i8, i8* %p, align 1
8+
%conv = uitofp i8 %0 to double
9+
call void @bar(double %conv)
10+
ret void
11+
12+
; CHECK-LABEL: @foo1
13+
; CHECK: mtvsrwz
14+
}
15+
16+
define void @foo2(i16* %p) {
17+
entry:
18+
%0 = load i16, i16* %p, align 2
19+
%conv = uitofp i16 %0 to double
20+
call void @bar(double %conv)
21+
ret void
22+
23+
; CHECK-LABEL: @foo2
24+
; CHECK: mtvsrwz
25+
}
26+

0 commit comments

Comments
 (0)