Skip to content

Commit 5e1b0f9

Browse files
[llvm] Use llvm::less_first and llvm::less_second (NFC) (#136272)
1 parent c244dae commit 5e1b0f9

File tree

3 files changed

+6
-15
lines changed

3 files changed

+6
-15
lines changed

llvm/lib/Target/AMDGPU/AMDGPUIGroupLP.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,8 @@ void PipelineSolver::populateReadyList(
588588
ReadyList.push_back(std::pair(*I, -1));
589589
}
590590

591-
if (UseCostHeur) {
592-
std::sort(ReadyList.begin(), ReadyList.end(),
593-
[](std::pair<int, int> A, std::pair<int, int> B) {
594-
return A.second < B.second;
595-
});
596-
}
591+
if (UseCostHeur)
592+
llvm::sort(ReadyList, llvm::less_second());
597593

598594
assert(ReadyList.size() == CurrSU.second.size());
599595
}

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6466,10 +6466,7 @@ static bool clusterSortPtrAccesses(ArrayRef<Value *> VL,
64666466
for (auto &Base : Bases) {
64676467
for (auto &Vec : Base.second) {
64686468
if (Vec.size() > 1) {
6469-
stable_sort(Vec, [](const std::tuple<Value *, int, unsigned> &X,
6470-
const std::tuple<Value *, int, unsigned> &Y) {
6471-
return std::get<1>(X) < std::get<1>(Y);
6472-
});
6469+
stable_sort(Vec, llvm::less_second());
64736470
int InitialOffset = std::get<1>(Vec[0]);
64746471
bool AnyConsecutive =
64756472
all_of(enumerate(Vec), [InitialOffset](const auto &P) {
@@ -7986,9 +7983,7 @@ bool BoUpSLP::canFormVector(ArrayRef<StoreInst *> StoresVec,
79867983
// Check if the stores are consecutive by checking if their difference is 1.
79877984
if (StoreOffsetVec.size() != StoresVec.size())
79887985
return false;
7989-
sort(StoreOffsetVec,
7990-
[](const std::pair<int, unsigned> &L,
7991-
const std::pair<int, unsigned> &R) { return L.first < R.first; });
7986+
sort(StoreOffsetVec, llvm::less_first());
79927987
unsigned Idx = 0;
79937988
int PrevDist = 0;
79947989
for (const auto &P : StoreOffsetVec) {

llvm/tools/llvm-gpu-loader/nvptx.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ Expected<void *> get_ctor_dtor_array(const void *image, const size_t size,
8484
}
8585
// Lower priority constructors are run before higher ones. The reverse is true
8686
// for destructors.
87-
llvm::sort(ctors, [](auto x, auto y) { return x.second < y.second; });
88-
llvm::sort(dtors, [](auto x, auto y) { return x.second < y.second; });
87+
llvm::sort(ctors, llvm::less_second());
88+
llvm::sort(dtors, llvm::less_second());
8989

9090
// Allocate host pinned memory to make these arrays visible to the GPU.
9191
CUdeviceptr *dev_memory = reinterpret_cast<CUdeviceptr *>(allocator(

0 commit comments

Comments
 (0)