Skip to content

Commit cf401f7

Browse files
authored
[RISCV] Use Zacas for AtomicRMWInst::Nand i32 and XLen. (#80119)
We don't have an AMO instruction for Nand, so with the A extension we use an LR/SC loop. If we have Zacas we can use a CAS loop instead. According to the Zacas spec, a CAS loop scales to highly parallel systems better than LR/SC.
1 parent 40ebe52 commit cf401f7

File tree

3 files changed

+832
-352
lines changed

3 files changed

+832
-352
lines changed

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19514,6 +19514,11 @@ RISCVTargetLowering::shouldExpandAtomicRMWInIR(AtomicRMWInst *AI) const {
1951419514
unsigned Size = AI->getType()->getPrimitiveSizeInBits();
1951519515
if (Size == 8 || Size == 16)
1951619516
return AtomicExpansionKind::MaskedIntrinsic;
19517+
19518+
if (Subtarget.hasStdExtZacas() && AI->getOperation() == AtomicRMWInst::Nand &&
19519+
(Size == Subtarget.getXLen() || Size == 32))
19520+
return AtomicExpansionKind::CmpXChg;
19521+
1951719522
return AtomicExpansionKind::None;
1951819523
}
1951919524

0 commit comments

Comments
 (0)