]> granicus.if.org Git - llvm/commitdiff
[X86] Simplify the code that turns INSERT_SUBVECTOR into BLENDI. NFCI
authorCraig Topper <craig.topper@gmail.com>
Sat, 4 Feb 2017 23:26:42 +0000 (23:26 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sat, 4 Feb 2017 23:26:42 +0000 (23:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294111 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ISelLowering.cpp

index f4b81063bcc3c487bb17f5f099c54a7e3f8761fd..f51920f5e6e4b89524073035b1be8f18b836e344 100644 (file)
@@ -34123,32 +34123,21 @@ static SDValue combineInsertSubvector(SDNode *N, SelectionDAG &DAG,
   // we are not recursing on that node by checking for undef here.
   if (IdxVal == 0 && OpVT.is256BitVector() && SubVecVT.is128BitVector() &&
       !Vec.isUndef()) {
-    SDValue ZeroIndex = DAG.getIntPtrConstant(0, dl);
-    SDValue Undef = DAG.getUNDEF(OpVT);
-    SDValue Vec256 = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, OpVT, Undef,
-                                 SubVec, ZeroIndex);
+    SDValue Vec256 = DAG.getNode(ISD::INSERT_SUBVECTOR, dl, OpVT,
+                                 DAG.getUNDEF(OpVT), SubVec, N->getOperand(2));
 
-    // The blend instruction, and therefore its mask, depend on the data type.
-    MVT ScalarType = OpVT.getVectorElementType();
-    if (ScalarType.isFloatingPoint()) {
-      // Choose either vblendps (float) or vblendpd (double).
-      unsigned ScalarSize = ScalarType.getSizeInBits();
-      assert((ScalarSize == 64 || ScalarSize == 32) && "Unknown float type");
-      unsigned MaskVal = (ScalarSize == 64) ? 0x03 : 0x0f;
-      SDValue Mask = DAG.getConstant(MaskVal, dl, MVT::i8);
-      return DAG.getNode(X86ISD::BLENDI, dl, OpVT, Vec, Vec256, Mask);
-    }
-
-    // AVX2 is needed for 256-bit integer blend support.
     // Integers must be cast to 32-bit because there is only vpblendd;
     // vpblendw can't be used for this because it has a handicapped mask.
-
     // If we don't have AVX2, then cast to float. Using a wrong domain blend
     // is still more efficient than using the wrong domain vinsertf128 that
     // will be created by InsertSubVector().
-    MVT CastVT = Subtarget.hasAVX2() ? MVT::v8i32 : MVT::v8f32;
+    MVT CastVT = OpVT;
+    if (OpVT.isInteger())
+      CastVT = Subtarget.hasAVX2() ? MVT::v8i32 : MVT::v8f32;
 
-    SDValue Mask = DAG.getConstant(0x0f, dl, MVT::i8);
+    // The blend instruction, and therefore its mask, depend on the data type.
+    unsigned MaskVal = CastVT.getScalarSizeInBits() == 64 ? 0x03 : 0x0f;
+    SDValue Mask = DAG.getConstant(MaskVal, dl, MVT::i8);
     Vec = DAG.getBitcast(CastVT, Vec);
     Vec256 = DAG.getBitcast(CastVT, Vec256);
     Vec256 = DAG.getNode(X86ISD::BLENDI, dl, CastVT, Vec, Vec256, Mask);