[X86][SSE] Assert if the shuffle mask indices are not -1 or within a valid input...
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 8 Aug 2016 11:07:34 +0000 (11:07 +0000)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Mon, 8 Aug 2016 11:07:34 +0000 (11:07 +0000)
As discussed in post-review rL277959

llvm-svn: 277993

llvm/lib/Target/X86/X86ISelLowering.cpp

index 1fb3983..c09d76d 100644 (file)
@@ -12287,14 +12287,11 @@ static SDValue lowerVectorShuffle(SDValue Op, const X86Subtarget &Subtarget,
         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);
-  }
+  // Check for illegal shuffle mask element index values.
+  int MaskUpperLimit = Mask.size() * (V2IsUndef ? 1 : 2); (void)MaskUpperLimit;
+  assert(llvm::all_of(Mask,
+                      [&](int M) { return -1 <= M && M < MaskUpperLimit; }) &&
+         "Out of bounds shuffle index");
 
   // We actually see shuffles that are entirely re-arrangements of a set of
   // zero inputs. This mostly happens while decomposing complex shuffles into