Skip to content

Commit

Permalink
[VecCombine] Fix sort comparator logic in foldShuffleFromReductions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
davemgreen committed Apr 29, 2022
1 parent 884e9a8 commit 7047c47
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions llvm/lib/Transforms/Vectorize/VectorCombine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1200,9 +1200,7 @@ bool VectorCombine::foldShuffleFromReductions(Instruction &I) {
// become a identity or concat mask. Undef elements are pushed to the end.
SmallVector<int> ConcatMask;
Shuffle->getShuffleMask(ConcatMask);
sort(ConcatMask, [](int X, int Y) {
return Y == UndefMaskElem ? true : (X == UndefMaskElem ? false : X < Y);
});
sort(ConcatMask, [](int X, int Y) { return (unsigned)X < (unsigned)Y; });
bool UsesSecondVec =
any_of(ConcatMask, [&](int M) { return M >= NumInputElts; });
InstructionCost OldCost = TTI.getShuffleCost(
Expand Down

0 comments on commit 7047c47

Please sign in to comment.