[X86][SSE] createVariablePermute - move source vector canonicalization to top of...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 9 Mar 2018 18:08:08 +0000 (18:08 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 9 Mar 2018 18:08:08 +0000 (18:08 +0000)
This is to make it easier to return early from the switch statement with custom lowering.

llvm-svn: 327157

llvm/lib/Target/X86/X86ISelLowering.cpp

index 18d0cf0..e8265e7 100644 (file)
@@ -7926,6 +7926,14 @@ SDValue createVariablePermute(MVT VT, SDValue SrcVec, SDValue IndicesVec,
                                   NumElts * VT.getScalarSizeInBits());
   IndicesVec = DAG.getZExtOrTrunc(IndicesVec, SDLoc(IndicesVec), IndicesVT);
 
+  // Adjust SrcVec to match VT type.
+  if (SrcVec.getValueSizeInBits() > VT.getSizeInBits())
+    return SDValue();
+  else if (SrcVec.getValueSizeInBits() < VT.getSizeInBits())
+    SrcVec =
+        DAG.getNode(ISD::INSERT_SUBVECTOR, SDLoc(SrcVec), VT, DAG.getUNDEF(VT),
+                    SrcVec, DAG.getIntPtrConstant(0, SDLoc(SrcVec)));
+
   unsigned Opcode = 0;
   switch (VT.SimpleTy) {
   default:
@@ -8004,14 +8012,6 @@ SDValue createVariablePermute(MVT VT, SDValue SrcVec, SDValue IndicesVec,
          (VT.getScalarSizeInBits() % ShuffleVT.getScalarSizeInBits()) == 0 &&
          "Illegal variable permute shuffle type");
 
-  if (SrcVec.getValueSizeInBits() > VT.getSizeInBits())
-    return SDValue();
-  else if (SrcVec.getValueSizeInBits() < VT.getSizeInBits()) {
-    SrcVec =
-        DAG.getNode(ISD::INSERT_SUBVECTOR, SDLoc(SrcVec), VT, DAG.getUNDEF(VT),
-                    SrcVec, DAG.getIntPtrConstant(0, SDLoc(SrcVec)));
-  }
-
   uint64_t Scale = VT.getScalarSizeInBits() / ShuffleVT.getScalarSizeInBits();
   if (Scale > 1) {
     assert(isPowerOf2_64(Scale) && "Illegal variable permute shuffle scale");