@@ -2053,8 +2053,8 @@ static bool isSingleSourceMaskImpl(ArrayRef<int> Mask, int NumOpElts) {
2053
2053
if (UsesLHS && UsesRHS)
2054
2054
return false ;
2055
2055
}
2056
- assert ((UsesLHS ^ UsesRHS) && " Should have selected from exactly 1 source" );
2057
- return true ;
2056
+ // Allow for degenerate case: completely undef mask means neither source is used.
2057
+ return UsesLHS || UsesRHS ;
2058
2058
}
2059
2059
2060
2060
bool ShuffleVectorInst::isSingleSourceMask (ArrayRef<int > Mask) {
@@ -2182,6 +2182,8 @@ bool ShuffleVectorInst::isExtractSubvectorMask(ArrayRef<int> Mask,
2182
2182
}
2183
2183
2184
2184
bool ShuffleVectorInst::isIdentityWithPadding () const {
2185
+ if (isa<UndefValue>(Op<2 >()))
2186
+ return false ;
2185
2187
int NumOpElts = cast<VectorType>(Op<0 >()->getType ())->getNumElements ();
2186
2188
int NumMaskElts = cast<VectorType>(getType ())->getNumElements ();
2187
2189
if (NumMaskElts <= NumOpElts)
@@ -2201,6 +2203,8 @@ bool ShuffleVectorInst::isIdentityWithPadding() const {
2201
2203
}
2202
2204
2203
2205
bool ShuffleVectorInst::isIdentityWithExtract () const {
2206
+ if (isa<UndefValue>(Op<2 >()))
2207
+ return false ;
2204
2208
int NumOpElts = cast<VectorType>(Op<0 >()->getType ())->getNumElements ();
2205
2209
int NumMaskElts = getType ()->getNumElements ();
2206
2210
if (NumMaskElts >= NumOpElts)
@@ -2211,7 +2215,8 @@ bool ShuffleVectorInst::isIdentityWithExtract() const {
2211
2215
2212
2216
bool ShuffleVectorInst::isConcat () const {
2213
2217
// Vector concatenation is differentiated from identity with padding.
2214
- if (isa<UndefValue>(Op<0 >()) || isa<UndefValue>(Op<1 >()))
2218
+ if (isa<UndefValue>(Op<0 >()) || isa<UndefValue>(Op<1 >()) ||
2219
+ isa<UndefValue>(Op<2 >()))
2215
2220
return false ;
2216
2221
2217
2222
int NumOpElts = cast<VectorType>(Op<0 >()->getType ())->getNumElements ();
0 commit comments