FEX icon indicating copy to clipboard operation
FEX copied to clipboard

Incorrect translation of cmpxchg8b

Open simon902 opened this issue 7 months ago • 1 comments

The instruction cmpxchg8b qword ptr [rbp] gets translated to the following incorrect ARM code:

mov    x20, x4
mov    x21, x5
caspal w20, w21, w6, w7, [x9]
mrs    x0, NZCV
cmp    w20, w4
ccmp   w21, w5, #0, eq
rmif   x0, #0, #0xb
csel   x4, x20, x4, ne
csel   x5, x21, x5, ne

Observe that rmif is used with a shift value of 0 whereas a shift value of 28 is required to extract the NZCV bits.

simon902 avatar Apr 24 '26 06:04 simon902

Fixed in #5435, which amalgamates #5431 with necessary unit tests. Thanks for the report and fix! This was a gnarly one.

lioncash avatar Apr 25 '26 16:04 lioncash