Skip to content

Commit 7047c47

Browse files
committed
[VecCombine] Fix sort comparator logic in foldShuffleFromReductions
I think this sort comparator was overly complex, and the windows expensive check bot agreed, failing as it was not giving a strict weak ordering. Change it to use the comparison of the mask values as unsigned integers. This should sort the undef elements to the end whilst keeping X<Y otherwise.
1 parent 884e9a8 commit 7047c47

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

llvm/lib/Transforms/Vectorize/VectorCombine.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,9 +1200,7 @@ bool VectorCombine::foldShuffleFromReductions(Instruction &I) {
12001200
// become a identity or concat mask. Undef elements are pushed to the end.
12011201
SmallVector<int> ConcatMask;
12021202
Shuffle->getShuffleMask(ConcatMask);
1203-
sort(ConcatMask, [](int X, int Y) {
1204-
return Y == UndefMaskElem ? true : (X == UndefMaskElem ? false : X < Y);
1205-
});
1203+
sort(ConcatMask, [](int X, int Y) { return (unsigned)X < (unsigned)Y; });
12061204
bool UsesSecondVec =
12071205
any_of(ConcatMask, [&](int M) { return M >= NumInputElts; });
12081206
InstructionCost OldCost = TTI.getShuffleCost(

0 commit comments

Comments
 (0)