Skip to content

Commit

Permalink
Alternative fix for ARM64 signed small type cmpxchg without LSE (#97902)
Browse files Browse the repository at this point in the history
* Alternative fix for ARM64 signed small type cmpxchg without LSE

Better fix for #97839.

* Update importercalls.cpp

* Update importercalls.cpp

* Add comment
  • Loading branch information
MichalPetryka authored Feb 19, 2024
1 parent 1be948c commit b473606
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/coreclr/jit/gtlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ GTNODE(XAND , GenTreeOp ,0,1,GTK_BINOP)
GTNODE(XORR , GenTreeOp ,0,1,GTK_BINOP)
GTNODE(XADD , GenTreeOp ,0,1,GTK_BINOP)
GTNODE(XCHG , GenTreeOp ,0,1,GTK_BINOP)
GTNODE(CMPXCHG , GenTreeCmpXchg ,0,1,GTK_SPECIAL)
GTNODE(CMPXCHG , GenTreeCmpXchg ,0,1,GTK_SPECIAL) // atomic CAS, small types need the comparand to be zero extended

GTNODE(IND , GenTreeIndir ,0,1,GTK_UNOP) // Load indirection
GTNODE(STOREIND , GenTreeStoreInd ,0,1,GTK_BINOP|GTK_EXOP|GTK_NOVALUE|GTK_STORE) // Store indirection
Expand Down
5 changes: 5 additions & 0 deletions src/coreclr/jit/importercalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3470,6 +3470,11 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis,
assert(sig->numArgs == 3);

GenTree* op3 = impPopStack().val; // comparand
if (varTypeIsSmall(callType))
{
// small types need the comparand to have its upper bits zeroed
op3 = gtNewCastNode(genActualType(callType), op3, /* uns */ false, varTypeToUnsigned(callType));
}
GenTree* op2 = impPopStack().val; // value
GenTree* op1 = impPopStack().val; // location
retNode = gtNewAtomicNode(GT_CMPXCHG, callType, op1, op2, op3);
Expand Down

0 comments on commit b473606

Please sign in to comment.