AVX2: Add an additional broadcast idiom.
authorNadav Rotem <nadav.rotem@intel.com>
Thu, 10 May 2012 12:39:13 +0000 (12:39 +0000)
committerNadav Rotem <nadav.rotem@intel.com>
Thu, 10 May 2012 12:39:13 +0000 (12:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156540 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp
test/CodeGen/X86/avx-vbroadcast.ll

index 4a312f4eb563ce9bec570de76b0e72c83b1919bf..a7e72e05f7a55b17cad1e500afea4aeaf73e2fa7 100644 (file)
@@ -4980,8 +4980,11 @@ X86TargetLowering::LowerVectorBroadcast(SDValue &Op, SelectionDAG &DAG) const {
         return SDValue();
 
       SDValue Sc = Op.getOperand(0);
-      if (Sc.getOpcode() != ISD::SCALAR_TO_VECTOR)
-        return SDValue();
+      if (Sc.getOpcode() == ISD::SCALAR_TO_VECTOR)
+        Ld = Sc.getOperand(0);
+      else if (Sc.getOpcode() == ISD::BUILD_VECTOR)
+        Ld = Sc.getOperand(0);
+      else return SDValue();
 
       Ld = Sc.getOperand(0);
       ConstSplatVal = (Ld.getOpcode() == ISD::Constant ||
index 26ee1d33a175a9b60b7e4d52d535c53cd7a38abd..0d403d4bb124e80c21b80e411f0c8e5977528f3f 100644 (file)
@@ -129,3 +129,15 @@ entry:
   ret <4 x float> %vecinit6.i
 }
 
+
+; CHECK: _RR2
+; CHECK: vbroadcastss (%
+; CHECK: ret
+define <4 x float> @_RR2(float* %ptr, i32* %k) nounwind uwtable readnone ssp {
+entry:
+  %q = load float* %ptr, align 4
+  %v = insertelement <4 x float> undef, float %q, i32 0
+  %t = shufflevector <4 x float> %v, <4 x float> undef, <4 x i32> zeroinitializer
+  ret <4 x float> %t
+}
+