[llvm] 0ba4767 - [AMDGPU] Cosmetic tweaks in AMDGPUAtomicOptimizer. NFC. (#129081)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 28 02:09:56 PST 2025
Author: Jay Foad
Date: 2025-02-28T10:09:53Z
New Revision: 0ba4767feac7878044b1352d86806e8e5a9bcf29
URL: https://github.com/llvm/llvm-project/commit/0ba4767feac7878044b1352d86806e8e5a9bcf29
DIFF: https://github.com/llvm/llvm-project/commit/0ba4767feac7878044b1352d86806e8e5a9bcf29.diff
LOG: [AMDGPU] Cosmetic tweaks in AMDGPUAtomicOptimizer. NFC. (#129081)
Simplify iteration over the ToReplace vector, and some related cosmetic
cleanups.
Added:
Modified:
llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp b/llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
index e46d0587e7943..76b1775f0d096 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAtomicOptimizer.cpp
@@ -151,23 +151,18 @@ PreservedAnalyses AMDGPUAtomicOptimizerPass::run(Function &F,
}
bool AMDGPUAtomicOptimizerImpl::run() {
-
// Scan option None disables the Pass
- if (ScanImpl == ScanOptions::None) {
+ if (ScanImpl == ScanOptions::None)
return false;
- }
visit(F);
+ if (ToReplace.empty())
+ return false;
- const bool Changed = !ToReplace.empty();
-
- for (ReplacementInfo &Info : ToReplace) {
- optimizeAtomic(*Info.I, Info.Op, Info.ValIdx, Info.ValDivergent);
- }
-
+ for (auto &[I, Op, ValIdx, ValDivergent] : ToReplace)
+ optimizeAtomic(*I, Op, ValIdx, ValDivergent);
ToReplace.clear();
-
- return Changed;
+ return true;
}
static bool isLegalCrossLaneType(Type *Ty) {
@@ -247,9 +242,7 @@ void AMDGPUAtomicOptimizerImpl::visitAtomicRMWInst(AtomicRMWInst &I) {
// If we get here, we can optimize the atomic using a single wavefront-wide
// atomic operation to do the calculation for the entire wavefront, so
// remember the instruction so we can come back to it.
- const ReplacementInfo Info = {&I, Op, ValIdx, ValDivergent};
-
- ToReplace.push_back(Info);
+ ToReplace.push_back({&I, Op, ValIdx, ValDivergent});
}
void AMDGPUAtomicOptimizerImpl::visitIntrinsicInst(IntrinsicInst &I) {
@@ -333,17 +326,14 @@ void AMDGPUAtomicOptimizerImpl::visitIntrinsicInst(IntrinsicInst &I) {
// If any of the other arguments to the intrinsic are divergent, we can't
// optimize the operation.
for (unsigned Idx = 1; Idx < I.getNumOperands(); Idx++) {
- if (UA.isDivergentUse(I.getOperandUse(Idx))) {
+ if (UA.isDivergentUse(I.getOperandUse(Idx)))
return;
- }
}
// If we get here, we can optimize the atomic using a single wavefront-wide
// atomic operation to do the calculation for the entire wavefront, so
// remember the instruction so we can come back to it.
- const ReplacementInfo Info = {&I, Op, ValIdx, ValDivergent};
-
- ToReplace.push_back(Info);
+ ToReplace.push_back({&I, Op, ValIdx, ValDivergent});
}
// Use the builder to create the non-atomic counterpart of the specified
More information about the llvm-commits
mailing list