[llvm] c8626cd - [LoopSink] Don't sort BBs if there is only 1 of them (NFC)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 16 01:06:05 PDT 2023
Author: Danila Kutenin
Date: 2023-08-16T10:03:21+02:00
New Revision: c8626cd916ac07f6e6c4e3ba20c089589b878847
URL: https://github.com/llvm/llvm-project/commit/c8626cd916ac07f6e6c4e3ba20c089589b878847
DIFF: https://github.com/llvm/llvm-project/commit/c8626cd916ac07f6e6c4e3ba20c089589b878847.diff
LOG: [LoopSink] Don't sort BBs if there is only 1 of them (NFC)
This was trigerred by the debug check when comp(a, a) was called.
On line 216 it's checked that LoopBlockNumber should contain
all if there are more than 1. NFC for end users
Differential Revision: https://reviews.llvm.org/D157954
Added:
Modified:
llvm/lib/Transforms/Scalar/LoopSink.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/LoopSink.cpp b/llvm/lib/Transforms/Scalar/LoopSink.cpp
index 597c159682c5c0..4d51f0566310c1 100644
--- a/llvm/lib/Transforms/Scalar/LoopSink.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopSink.cpp
@@ -222,9 +222,11 @@ static bool sinkInstruction(
// order. No need to stable sort as the block numbers are a total ordering.
SmallVector<BasicBlock *, 2> SortedBBsToSinkInto;
llvm::append_range(SortedBBsToSinkInto, BBsToSinkInto);
- llvm::sort(SortedBBsToSinkInto, [&](BasicBlock *A, BasicBlock *B) {
- return LoopBlockNumber.find(A)->second < LoopBlockNumber.find(B)->second;
- });
+ if (SortedBBsToSinkInto.size() > 1) {
+ llvm::sort(SortedBBsToSinkInto, [&](BasicBlock *A, BasicBlock *B) {
+ return LoopBlockNumber.find(A)->second < LoopBlockNumber.find(B)->second;
+ });
+ }
BasicBlock *MoveBB = *SortedBBsToSinkInto.begin();
// FIXME: Optimize the efficiency for cloned value replacement. The current
More information about the llvm-commits
mailing list