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