[llvm] r277959 - [X86] lowerVectorShuffle - ensure that undefined mask elements only use SM_SentinelUndef

Simon Pilgrim via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 7 08:29:12 PDT 2016


Author: rksimon
Date: Sun Aug  7 10:29:12 2016
New Revision: 277959

URL: http://llvm.org/viewvc/llvm-project?rev=277959&view=rev
Log:
[X86] lowerVectorShuffle - ensure that undefined mask elements only use SM_SentinelUndef

Help lowering and combining (which can specify SM_SentinelZero mask elements) share more shuffle matching code.

Modified:
    llvm/trunk/lib/Target/X86/X86ISelLowering.cpp

Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=277959&r1=277958&r2=277959&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Sun Aug  7 10:29:12 2016
@@ -12281,6 +12281,15 @@ static SDValue lowerVectorShuffle(SDValu
         return DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
       }
 
+  // Ensure that undefined mask elements only use SM_SentinelUndef.
+  if (llvm::any_of(Mask, [](int M) { return M < SM_SentinelUndef; })) {
+    SmallVector<int, 8> NewMask(Mask.begin(), Mask.end());
+    for (int &M : NewMask)
+      if (M < SM_SentinelUndef)
+        M = SM_SentinelUndef;
+    return DAG.getVectorShuffle(VT, DL, V1, V2, NewMask);
+  }
+
   // We actually see shuffles that are entirely re-arrangements of a set of
   // zero inputs. This mostly happens while decomposing complex shuffles into
   // simple ones. Directly lower these as a buildvector of zeros.




More information about the llvm-commits mailing list