@@ -151,23 +151,18 @@ PreservedAnalyses AMDGPUAtomicOptimizerPass::run(Function &F,
151151}
152152
153153bool AMDGPUAtomicOptimizerImpl::run () {
154-
155154 // Scan option None disables the Pass
156- if (ScanImpl == ScanOptions::None) {
155+ if (ScanImpl == ScanOptions::None)
157156 return false ;
158- }
159157
160158 visit (F);
159+ if (ToReplace.empty ())
160+ return false ;
161161
162- const bool Changed = !ToReplace.empty ();
163-
164- for (ReplacementInfo &Info : ToReplace) {
165- optimizeAtomic (*Info.I , Info.Op , Info.ValIdx , Info.ValDivergent );
166- }
167-
162+ for (auto &[I, Op, ValIdx, ValDivergent] : ToReplace)
163+ optimizeAtomic (*I, Op, ValIdx, ValDivergent);
168164 ToReplace.clear ();
169-
170- return Changed;
165+ return true ;
171166}
172167
173168static bool isLegalCrossLaneType (Type *Ty) {
@@ -247,9 +242,7 @@ void AMDGPUAtomicOptimizerImpl::visitAtomicRMWInst(AtomicRMWInst &I) {
247242 // If we get here, we can optimize the atomic using a single wavefront-wide
248243 // atomic operation to do the calculation for the entire wavefront, so
249244 // remember the instruction so we can come back to it.
250- const ReplacementInfo Info = {&I, Op, ValIdx, ValDivergent};
251-
252- ToReplace.push_back (Info);
245+ ToReplace.push_back ({&I, Op, ValIdx, ValDivergent});
253246}
254247
255248void AMDGPUAtomicOptimizerImpl::visitIntrinsicInst (IntrinsicInst &I) {
@@ -333,17 +326,14 @@ void AMDGPUAtomicOptimizerImpl::visitIntrinsicInst(IntrinsicInst &I) {
333326 // If any of the other arguments to the intrinsic are divergent, we can't
334327 // optimize the operation.
335328 for (unsigned Idx = 1 ; Idx < I.getNumOperands (); Idx++) {
336- if (UA.isDivergentUse (I.getOperandUse (Idx))) {
329+ if (UA.isDivergentUse (I.getOperandUse (Idx)))
337330 return ;
338- }
339331 }
340332
341333 // If we get here, we can optimize the atomic using a single wavefront-wide
342334 // atomic operation to do the calculation for the entire wavefront, so
343335 // remember the instruction so we can come back to it.
344- const ReplacementInfo Info = {&I, Op, ValIdx, ValDivergent};
345-
346- ToReplace.push_back (Info);
336+ ToReplace.push_back ({&I, Op, ValIdx, ValDivergent});
347337}
348338
349339// Use the builder to create the non-atomic counterpart of the specified
0 commit comments