new test cases for branch solving

This commit is contained in:
G0lge
2024-07-23 22:43:04 +03:00
parent ce56044a38
commit 5ee8d46e54
2 changed files with 31 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
section .text
global main
main:
cmp rax, 0 ; zf = rax-0 == 0 ; sf = rax-0 < 0; of = (rax ^ 0) < 0; ....
jns cond_not_taken_sf ; sf == 0; if not taken, we can say rax is negative, so rax | 18446744073709551616 (sign bit is set)
condition_taken_sf: ; so the basic block here will assume rax's msb is set
shr rax, 63 ; rax will be 1
cond_not_taken_sf: ; but this basicblock wont assume rax is 0
ret
+16
View File
@@ -0,0 +1,16 @@
section .text
global main
main:
cmp rax, 0 ; zf = rax-0 == 0 ; sf = rax-0 < 0; of = (rax ^ 0) < 0; ....
jnz cond_not_taken_zf ; zf == 0; if not taken, we can say rax is 0 for this branch, we can do this by rax & 0.
condition_taken_zf: ; so the basic block here will assume rax is 0
inc rax ; rax will be 1
cond_not_taken_zf: ; but this basicblock wont assume rax is 0
ret