Skip to content

Commit 6a9e987

Browse files
committed
[VectorCombine] foldPermuteOfBinops - ensure potential identity mask isn't length changing.
1 parent aae2592 commit 6a9e987

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,8 +1639,12 @@ bool VectorCombine::foldPermuteOfBinops(Instruction &I) {
16391639
}
16401640

16411641
unsigned NumOpElts = Op0Ty->getNumElements();
1642-
bool IsIdentity0 = ShuffleVectorInst::isIdentityMask(NewMask0, NumOpElts);
1643-
bool IsIdentity1 = ShuffleVectorInst::isIdentityMask(NewMask1, NumOpElts);
1642+
bool IsIdentity0 =
1643+
all_of(NewMask0, [NumOpElts](int M) { return M < (int)NumOpElts; }) &&
1644+
ShuffleVectorInst::isIdentityMask(NewMask0, NumOpElts);
1645+
bool IsIdentity1 =
1646+
all_of(NewMask1, [NumOpElts](int M) { return M < (int)NumOpElts; }) &&
1647+
ShuffleVectorInst::isIdentityMask(NewMask1, NumOpElts);
16441648

16451649
// Try to merge shuffles across the binop if the new shuffles are not costly.
16461650
InstructionCost OldCost =

0 commit comments

Comments
 (0)