@@ -151,23 +151,18 @@ PreservedAnalyses AMDGPUAtomicOptimizerPass::run(Function &F,
151
151
}
152
152
153
153
bool AMDGPUAtomicOptimizerImpl::run () {
154
-
155
154
// Scan option None disables the Pass
156
- if (ScanImpl == ScanOptions::None) {
155
+ if (ScanImpl == ScanOptions::None)
157
156
return false ;
158
- }
159
157
160
158
visit (F);
159
+ if (ToReplace.empty ())
160
+ return false ;
161
161
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);
168
164
ToReplace.clear ();
169
-
170
- return Changed;
165
+ return true ;
171
166
}
172
167
173
168
static bool isLegalCrossLaneType (Type *Ty) {
@@ -247,9 +242,7 @@ void AMDGPUAtomicOptimizerImpl::visitAtomicRMWInst(AtomicRMWInst &I) {
247
242
// If we get here, we can optimize the atomic using a single wavefront-wide
248
243
// atomic operation to do the calculation for the entire wavefront, so
249
244
// 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});
253
246
}
254
247
255
248
void AMDGPUAtomicOptimizerImpl::visitIntrinsicInst (IntrinsicInst &I) {
@@ -333,17 +326,14 @@ void AMDGPUAtomicOptimizerImpl::visitIntrinsicInst(IntrinsicInst &I) {
333
326
// If any of the other arguments to the intrinsic are divergent, we can't
334
327
// optimize the operation.
335
328
for (unsigned Idx = 1 ; Idx < I.getNumOperands (); Idx++) {
336
- if (UA.isDivergentUse (I.getOperandUse (Idx))) {
329
+ if (UA.isDivergentUse (I.getOperandUse (Idx)))
337
330
return ;
338
- }
339
331
}
340
332
341
333
// If we get here, we can optimize the atomic using a single wavefront-wide
342
334
// atomic operation to do the calculation for the entire wavefront, so
343
335
// 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});
347
337
}
348
338
349
339
// Use the builder to create the non-atomic counterpart of the specified
0 commit comments