FEX/unittests/ASM/FEX_bugs/nzcv_rmw.asm
Alyssa Rosenzweig 59c3f96a23 unittests: add test for deferred flags + shift with cl=0
this failed on an earlier version of the series that otherwise passed ci.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
2024-04-05 20:34:05 -04:00

39 lines
668 B
NASM

%ifdef CONFIG
{
"RegData": {
"RAX": "0xcafe"
}
}
%endif
; FEX had a bug where an NZCV RMW would fail to calculate previously deferred
; flags, resulting in garbage flag values
; First zero NZCV and break visibility
mov rax, 0
add rax, 1
jz fexi_fexi_im_so_broken
jmp .begin
.begin:
; NZCV is zero. Set it to something nonzero with a deferred flag operation.
mov rax, 0
popcnt rax, rax
; Now do a variable shift that preserves flags. This would clear ZF if not for
; the condition on the shift flags.
mov rbx, 100
mov cl, 0
sar rbx, cl
; ZF should still be set.
jnz fexi_fexi_im_so_broken
mov rax, 0xcafe
hlt
fexi_fexi_im_so_broken:
mov rax, 0xdead
hlt