[AArch64] Use the CMP_SWAP_128 variants added in 843c6140.

Accidentally forgot to flip the opcode... and I didn't notice because it
was working fine for the GlobalISel.
This commit is contained in:
Eli Friedman 2021-07-20 13:20:02 -07:00
parent 05a6d74c48
commit 664a1fd9f0
2 changed files with 23 additions and 4 deletions

View File

@ -17055,13 +17055,32 @@ static void ReplaceCMP_SWAP_128Results(SDNode *N,
return; return;
} }
unsigned Opcode;
switch (MemOp->getMergedOrdering()) {
case AtomicOrdering::Monotonic:
Opcode = AArch64::CMP_SWAP_128_MONOTONIC;
break;
case AtomicOrdering::Acquire:
Opcode = AArch64::CMP_SWAP_128_ACQUIRE;
break;
case AtomicOrdering::Release:
Opcode = AArch64::CMP_SWAP_128_RELEASE;
break;
case AtomicOrdering::AcquireRelease:
case AtomicOrdering::SequentiallyConsistent:
Opcode = AArch64::CMP_SWAP_128;
break;
default:
llvm_unreachable("Unexpected ordering!");
}
auto Desired = splitInt128(N->getOperand(2), DAG); auto Desired = splitInt128(N->getOperand(2), DAG);
auto New = splitInt128(N->getOperand(3), DAG); auto New = splitInt128(N->getOperand(3), DAG);
SDValue Ops[] = {N->getOperand(1), Desired.first, Desired.second, SDValue Ops[] = {N->getOperand(1), Desired.first, Desired.second,
New.first, New.second, N->getOperand(0)}; New.first, New.second, N->getOperand(0)};
SDNode *CmpSwap = DAG.getMachineNode( SDNode *CmpSwap = DAG.getMachineNode(
AArch64::CMP_SWAP_128, SDLoc(N), Opcode, SDLoc(N), DAG.getVTList(MVT::i64, MVT::i64, MVT::i32, MVT::Other),
DAG.getVTList(MVT::i64, MVT::i64, MVT::i32, MVT::Other), Ops); Ops);
DAG.setNodeMemRefs(cast<MachineSDNode>(CmpSwap), {MemOp}); DAG.setNodeMemRefs(cast<MachineSDNode>(CmpSwap), {MemOp});
Results.push_back(DAG.getNode(ISD::BUILD_PAIR, SDLoc(N), MVT::i128, Results.push_back(DAG.getNode(ISD::BUILD_PAIR, SDLoc(N), MVT::i128,

View File

@ -13,11 +13,11 @@ define i128 @val_compare_and_swap(i128* %p, i128 %oldval, i128 %newval) {
; CHECK: cmp ; CHECK: cmp
; CHECK: cinc [[MISMATCH:w[0-9]+]] ; CHECK: cinc [[MISMATCH:w[0-9]+]]
; CHECK: cbz [[MISMATCH]], [[EQUAL:.LBB[0-9]+_[0-9]+]] ; CHECK: cbz [[MISMATCH]], [[EQUAL:.LBB[0-9]+_[0-9]+]]
; CHECK: stlxp [[SCRATCH_RES:w[0-9]+]], [[RESULTLO]], [[RESULTHI]], [x[[ADDR]]] ; CHECK: stxp [[SCRATCH_RES:w[0-9]+]], [[RESULTLO]], [[RESULTHI]], [x[[ADDR]]]
; CHECK: cbnz [[SCRATCH_RES]], [[LABEL]] ; CHECK: cbnz [[SCRATCH_RES]], [[LABEL]]
; CHECK: b [[DONE:.LBB[0-9]+_[0-9]+]] ; CHECK: b [[DONE:.LBB[0-9]+_[0-9]+]]
; CHECK: [[EQUAL]]: ; CHECK: [[EQUAL]]:
; CHECK: stlxp [[SCRATCH_RES:w[0-9]+]], x4, x5, [x[[ADDR]]] ; CHECK: stxp [[SCRATCH_RES:w[0-9]+]], x4, x5, [x[[ADDR]]]
; CHECK: cbnz [[SCRATCH_RES]], [[LABEL]] ; CHECK: cbnz [[SCRATCH_RES]], [[LABEL]]
; CHECK: [[DONE]]: ; CHECK: [[DONE]]:
%pair = cmpxchg i128* %p, i128 %oldval, i128 %newval acquire acquire %pair = cmpxchg i128* %p, i128 %oldval, i128 %newval acquire acquire