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