Skip to content

Commit daf9612

Browse files
committed
Move instruction handling cases together
1 parent f3da020 commit daf9612

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

llvm/lib/CodeGen/AtomicExpandPass.cpp

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ bool AtomicExpandImpl::processAtomicInstr(Instruction *I) {
211211
auto *RMWI = dyn_cast<AtomicRMWInst>(I);
212212
auto *CASI = dyn_cast<AtomicCmpXchgInst>(I);
213213

214+
bool MadeChange = false;
215+
214216
// If the Size/Alignment is not supported, replace with a libcall.
215217
if (LI) {
216218
if (!LI->isAtomic())
@@ -220,6 +222,12 @@ bool AtomicExpandImpl::processAtomicInstr(Instruction *I) {
220222
expandAtomicLoadToLibcall(LI);
221223
return true;
222224
}
225+
226+
if (TLI->shouldCastAtomicLoadInIR(LI) ==
227+
TargetLoweringBase::AtomicExpansionKind::CastToInteger) {
228+
I = LI = convertAtomicLoadToIntegerType(LI);
229+
MadeChange = true;
230+
}
223231
} else if (SI) {
224232
if (!SI->isAtomic())
225233
return false;
@@ -228,35 +236,29 @@ bool AtomicExpandImpl::processAtomicInstr(Instruction *I) {
228236
expandAtomicStoreToLibcall(SI);
229237
return true;
230238
}
239+
240+
if (TLI->shouldCastAtomicStoreInIR(SI) ==
241+
TargetLoweringBase::AtomicExpansionKind::CastToInteger) {
242+
I = SI = convertAtomicStoreToIntegerType(SI);
243+
MadeChange = true;
244+
}
231245
} else if (RMWI) {
232246
if (!atomicSizeSupported(TLI, RMWI)) {
233247
expandAtomicRMWToLibcall(RMWI);
234248
return true;
235249
}
250+
251+
if (TLI->shouldCastAtomicRMWIInIR(RMWI) ==
252+
TargetLoweringBase::AtomicExpansionKind::CastToInteger) {
253+
I = RMWI = convertAtomicXchgToIntegerType(RMWI);
254+
MadeChange = true;
255+
}
236256
} else if (CASI) {
237257
if (!atomicSizeSupported(TLI, CASI)) {
238258
expandAtomicCASToLibcall(CASI);
239259
return true;
240260
}
241-
} else
242-
return false;
243-
244-
bool MadeChange = false;
245261

246-
if (LI && TLI->shouldCastAtomicLoadInIR(LI) ==
247-
TargetLoweringBase::AtomicExpansionKind::CastToInteger) {
248-
I = LI = convertAtomicLoadToIntegerType(LI);
249-
MadeChange = true;
250-
} else if (SI && TLI->shouldCastAtomicStoreInIR(SI) ==
251-
TargetLoweringBase::AtomicExpansionKind::CastToInteger) {
252-
I = SI = convertAtomicStoreToIntegerType(SI);
253-
MadeChange = true;
254-
} else if (RMWI &&
255-
TLI->shouldCastAtomicRMWIInIR(RMWI) ==
256-
TargetLoweringBase::AtomicExpansionKind::CastToInteger) {
257-
I = RMWI = convertAtomicXchgToIntegerType(RMWI);
258-
MadeChange = true;
259-
} else if (CASI) {
260262
// TODO: when we're ready to make the change at the IR level, we can
261263
// extend convertCmpXchgToInteger for floating point too.
262264
if (CASI->getCompareOperand()->getType()->isPointerTy()) {
@@ -265,7 +267,8 @@ bool AtomicExpandImpl::processAtomicInstr(Instruction *I) {
265267
I = CASI = convertCmpXchgToIntegerType(CASI);
266268
MadeChange = true;
267269
}
268-
}
270+
} else
271+
return false;
269272

270273
if (TLI->shouldInsertFencesForAtomic(I)) {
271274
auto FenceOrdering = AtomicOrdering::Monotonic;

0 commit comments

Comments
 (0)