Blame 0001-PowerPC-Don-t-use-xscvdpspn-on-the-P7.patch

8c425be
From a481ab548d038c1dfd52ee211b997e2dd33ff5ae Mon Sep 17 00:00:00 2001
8c425be
From: Hal Finkel <hfinkel@anl.gov>
8c425be
Date: Wed, 6 Sep 2017 03:08:26 +0000
8c425be
Subject: [PATCH] [PowerPC] Don't use xscvdpspn on the P7
8c425be
8c425be
xscvdpspn was not introduced until the P8, so don't use it on the P7. Fixes a
8c425be
regression introduced in r288152.
8c425be
8c425be
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312612 91177308-0d34-0410-b5e6-96231b3b80d8
8c425be
---
8c425be
 lib/Target/PowerPC/PPCISelLowering.cpp |  9 ++++++---
8c425be
 test/CodeGen/PowerPC/fp-splat.ll       | 27 +++++++++++++++++++++++++++
8c425be
 2 files changed, 33 insertions(+), 3 deletions(-)
8c425be
 create mode 100644 test/CodeGen/PowerPC/fp-splat.ll
8c425be
8c425be
diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp
8c425be
index 74dedaf..6295693 100644
8c425be
--- a/lib/Target/PowerPC/PPCISelLowering.cpp
8c425be
+++ b/lib/Target/PowerPC/PPCISelLowering.cpp
8c425be
@@ -7463,9 +7463,11 @@ static SDValue BuildVSLDOI(SDValue LHS, SDValue RHS, unsigned Amt, EVT VT,
8c425be
 /// - The node is a "load-and-splat"
8c425be
 /// In all other cases, we will choose to keep the BUILD_VECTOR.
8c425be
 static bool haveEfficientBuildVectorPattern(BuildVectorSDNode *V,
8c425be
-                                            bool HasDirectMove) {
8c425be
+                                            bool HasDirectMove,
8c425be
+                                            bool HasP8Vector) {
8c425be
   EVT VecVT = V->getValueType(0);
8c425be
-  bool RightType = VecVT == MVT::v2f64 || VecVT == MVT::v4f32 ||
8c425be
+  bool RightType = VecVT == MVT::v2f64 ||
8c425be
+    (HasP8Vector && VecVT == MVT::v4f32) ||
8c425be
     (HasDirectMove && (VecVT == MVT::v2i64 || VecVT == MVT::v4i32));
8c425be
   if (!RightType)
8c425be
     return false;
8c425be
@@ -7627,7 +7629,8 @@ SDValue PPCTargetLowering::LowerBUILD_VECTOR(SDValue Op,
8c425be
     // lowered to VSX instructions under certain conditions.
8c425be
     // Without VSX, there is no pattern more efficient than expanding the node.
8c425be
     if (Subtarget.hasVSX() &&
8c425be
-        haveEfficientBuildVectorPattern(BVN, Subtarget.hasDirectMove()))
8c425be
+        haveEfficientBuildVectorPattern(BVN, Subtarget.hasDirectMove(),
8c425be
+                                        Subtarget.hasP8Vector()))
8c425be
       return Op;
8c425be
     return SDValue();
8c425be
   }
8c425be
diff --git a/test/CodeGen/PowerPC/fp-splat.ll b/test/CodeGen/PowerPC/fp-splat.ll
8c425be
new file mode 100644
8c425be
index 0000000..9b1ab21
8c425be
--- /dev/null
8c425be
+++ b/test/CodeGen/PowerPC/fp-splat.ll
8c425be
@@ -0,0 +1,27 @@
8c425be
+; RUN: llc -mcpu=pwr8 -mtriple=powerpc64le-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-P8 -check-prefix=CHECK
8c425be
+; RUN: llc -mcpu=pwr7 -mtriple=powerpc64-unknown-linux-gnu < %s | FileCheck %s -check-prefix=CHECK-P7 -check-prefix=CHECK
8c425be
+
8c425be
+define <4 x float> @test1(float %a) {
8c425be
+entry:
8c425be
+; CHECK-LABEL: test1
8c425be
+  %vecins = insertelement <4 x float> undef, float %a, i32 0
8c425be
+  %vecins1 = insertelement <4 x float> %vecins, float %a, i32 1
8c425be
+  %vecins2 = insertelement <4 x float> %vecins1, float %a, i32 2
8c425be
+  %vecins3 = insertelement <4 x float> %vecins2, float %a, i32 3
8c425be
+  ret <4 x float> %vecins3
8c425be
+; CHECK-P8: xscvdpspn
8c425be
+; CHECK-P7-NOT: xscvdpspn
8c425be
+; CHECK: blr
8c425be
+}
8c425be
+
8c425be
+define <2 x double> @test2(double %a) {
8c425be
+entry:
8c425be
+; CHECK-LABEL: test2
8c425be
+  %vecins = insertelement <2 x double> undef, double %a, i32 0
8c425be
+  %vecins1 = insertelement <2 x double> %vecins, double %a, i32 1
8c425be
+  ret <2 x double> %vecins1
8c425be
+; CHECK-P8: xxspltd
8c425be
+; CHECK-P7: xxspltd
8c425be
+; CHECK: blr
8c425be
+}
8c425be
+
8c425be
-- 
8c425be
1.8.3.1
8c425be