[PATCH] D27287: [PPC] Prefer direct move on power8 if load 1 or 2 bytes to VSR

Guozhi Wei via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 1 15:13:57 PST 2016


Carrot updated this revision to Diff 79991.
Carrot marked an inline comment as done.

https://reviews.llvm.org/D27287

Files:
  lib/Target/PowerPC/PPCISelLowering.cpp
  lib/Target/PowerPC/PPCISelLowering.h
  test/CodeGen/PowerPC/pr31144.ll


Index: test/CodeGen/PowerPC/pr31144.ll
===================================================================
--- test/CodeGen/PowerPC/pr31144.ll
+++ test/CodeGen/PowerPC/pr31144.ll
@@ -0,0 +1,28 @@
+; RUN: llc -mtriple=powerpc64le-unknown-linux-gnu -mcpu=pwr8 -mattr=+vsx < %s | FileCheck %s
+
+declare void @bar(double)
+
+define void @foo1(i8* %p) {
+entry:
+  %0 = load i8, i8* %p, align 1
+  %conv = uitofp i8 %0 to double
+  call void @bar(double %conv)
+  ret void
+
+; CHECK-LABEL: @foo1
+; CHECK:     mtvsrwz
+; CHECK-NOT: lxsiwzx
+}
+
+define void @foo2(i16* %p) {
+entry:
+  %0 = load i16, i16* %p, align 2
+  %conv = uitofp i16 %0 to double
+  call void @bar(double %conv)
+  ret void
+
+; CHECK-LABEL: @foo2
+; CHECK:       mtvsrwz
+; CHECK-NOT:   lxsiwzx
+}
+
Index: lib/Target/PowerPC/PPCISelLowering.h
===================================================================
--- lib/Target/PowerPC/PPCISelLowering.h
+++ lib/Target/PowerPC/PPCISelLowering.h
@@ -815,6 +815,8 @@
                                 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;
 
Index: lib/Target/PowerPC/PPCISelLowering.cpp
===================================================================
--- lib/Target/PowerPC/PPCISelLowering.cpp
+++ lib/Target/PowerPC/PPCISelLowering.cpp
@@ -6606,11 +6606,17 @@
 /// \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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D27287.79991.patch
Type: text/x-patch
Size: 2391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161201/af1ec29c/attachment.bin>


More information about the llvm-commits mailing list