[llvm] [LLVM] Use multi-argument std::min and std::max. NFC. (PR #206982)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 1 06:34:29 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-amdgpu
Author: Jay Foad (jayfoad)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/206982.diff
6 Files Affected:
- (modified) llvm/include/llvm/ADT/IntervalMap.h (+2-2)
- (modified) llvm/lib/Support/UnicodeNameToCodepoint.cpp (+1-1)
- (modified) llvm/lib/Target/AMDGPU/GCNSubtarget.cpp (+2-2)
- (modified) llvm/lib/Target/RISCV/RISCVISelLowering.cpp (+1-1)
- (modified) llvm/lib/TextAPI/RecordsSlice.cpp (+1-2)
- (modified) llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp (+1-2)
``````````diff
diff --git a/llvm/include/llvm/ADT/IntervalMap.h b/llvm/include/llvm/ADT/IntervalMap.h
index cb5943dc60e0e..345937066bd5d 100644
--- a/llvm/include/llvm/ADT/IntervalMap.h
+++ b/llvm/include/llvm/ADT/IntervalMap.h
@@ -320,12 +320,12 @@ class NodeBase {
int adjustFromLeftSib(unsigned Size, NodeBase &Sib, unsigned SSize, int Add) {
if (Add > 0) {
// We want to grow, copy from sib.
- unsigned Count = std::min(std::min(unsigned(Add), SSize), N - Size);
+ unsigned Count = std::min({unsigned(Add), SSize, N - Size});
Sib.transferToRightSib(SSize, *this, Size, Count);
return Count;
} else {
// We want to shrink, copy to sib.
- unsigned Count = std::min(std::min(unsigned(-Add), Size), N - SSize);
+ unsigned Count = std::min({unsigned(-Add), Size, N - SSize});
transferToLeftSib(Size, Sib, SSize, Count);
return -Count;
}
diff --git a/llvm/lib/Support/UnicodeNameToCodepoint.cpp b/llvm/lib/Support/UnicodeNameToCodepoint.cpp
index 3f5164a63279b..2cb22aff86573 100644
--- a/llvm/lib/Support/UnicodeNameToCodepoint.cpp
+++ b/llvm/lib/Support/UnicodeNameToCodepoint.cpp
@@ -514,7 +514,7 @@ nearestMatchesForCodepointName(StringRef Pattern, std::size_t MaxMatchesCount) {
const int Replace =
Get(I - 1, Row - 1) + (NormalizedName[I - 1] != N.Name[J] ? 1 : 0);
- Get(I, Row) = std::min(Insert, std::min(Delete, Replace));
+ Get(I, Row) = std::min({Insert, Delete, Replace});
}
Row++;
diff --git a/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp b/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp
index 23c92b9095e36..6d2e6568da2ad 100644
--- a/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp
+++ b/llvm/lib/Target/AMDGPU/GCNSubtarget.cpp
@@ -474,7 +474,7 @@ GCNSubtarget::computeOccupancy(const Function &F, unsigned LDSSize,
unsigned VGPROcc = getOccupancyWithNumVGPRs(NumVGPRs, DynamicVGPRBlockSize);
// Maximum occupancy may be further limited by high SGPR/VGPR usage.
- MaxOcc = std::min(MaxOcc, std::min(SGPROcc, VGPROcc));
+ MaxOcc = std::min({MaxOcc, SGPROcc, VGPROcc});
return {std::min(MinOcc, MaxOcc), MaxOcc};
}
@@ -635,7 +635,7 @@ GCNSubtarget::getMaxNumVectorRegs(const Function &F) const {
// Clamp values to be inbounds of our limits, and ensure min <= max.
MaxNumAGPRs = std::min(std::max(MinNumAGPRs, MaxNumAGPRs), MaxVectorRegs);
- MinNumAGPRs = std::min(std::min(MinNumAGPRs, TotalNumAGPRs), MaxNumAGPRs);
+ MinNumAGPRs = std::min({MinNumAGPRs, TotalNumAGPRs, MaxNumAGPRs});
MaxNumVGPRs = std::min(MaxVectorRegs - MinNumAGPRs, NumArchVGPRs);
MaxNumAGPRs = std::min(MaxVectorRegs - MaxNumVGPRs, MaxNumAGPRs);
diff --git a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
index f12d1dc1e1714..a945364003779 100644
--- a/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ b/llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -6728,7 +6728,7 @@ SDValue RISCVTargetLowering::lowerVECTOR_SHUFFLE(SDValue Op,
for (auto [I, M] : enumerate(Mask)) {
if (M == -1)
continue;
- MaxIdx = std::max(std::max((unsigned)I, (unsigned)M), MaxIdx);
+ MaxIdx = std::max({(unsigned)I, (unsigned)M, MaxIdx});
}
unsigned NewNumElts =
std::max((uint64_t)MinVLMAX, PowerOf2Ceil(MaxIdx + 1));
diff --git a/llvm/lib/TextAPI/RecordsSlice.cpp b/llvm/lib/TextAPI/RecordsSlice.cpp
index 1d04b63606522..91ad2556e46b8 100644
--- a/llvm/lib/TextAPI/RecordsSlice.cpp
+++ b/llvm/lib/TextAPI/RecordsSlice.cpp
@@ -124,8 +124,7 @@ void ObjCInterfaceRecord::updateLinkageForSymbols(ObjCIFSymbolKind SymType,
// linkages, in this case assign the largest one, when querying the linkage of
// the record itself. This allows visitors pick whether they want to account
// for complete symbol information.
- Linkage =
- std::max(Linkages.Class, std::max(Linkages.MetaClass, Linkages.EHType));
+ Linkage = std::max({Linkages.Class, Linkages.MetaClass, Linkages.EHType});
}
ObjCInterfaceRecord *RecordsSlice::findObjCInterface(StringRef Name) const {
diff --git a/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp b/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp
index 0318429a76a7b..e5117f6a0e4bb 100644
--- a/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp
+++ b/llvm/lib/Transforms/Utils/ASanStackFrameLayout.cpp
@@ -66,8 +66,7 @@ ComputeASanStackFrameLayout(SmallVectorImpl<ASanStackVariableDescription> &Vars,
ASanStackFrameLayout Layout;
Layout.Granularity = Granularity;
Layout.FrameAlignment = std::max(Granularity, Vars[0].Alignment);
- uint64_t Offset =
- std::max(std::max(MinHeaderSize, Granularity), Vars[0].Alignment);
+ uint64_t Offset = std::max({MinHeaderSize, Granularity, Vars[0].Alignment});
assert((Offset % Granularity) == 0);
for (size_t i = 0; i < NumVars; i++) {
bool IsLast = i == NumVars - 1;
``````````
</details>
https://github.com/llvm/llvm-project/pull/206982
More information about the llvm-commits
mailing list