Files
wasmtime/cranelift/filetests/filetests/isa/x64/div-checks.clif
2021-09-29 16:13:46 +02:00

53 lines
1.2 KiB
Plaintext

test compile
set avoid_div_traps=false
target x86_64
;; We should get the checked-div/rem sequence (`srem` pseudoinst below) even
;; when `avoid_div_traps` above is false (i.e. even when the host is normally
;; willing to accept SIGFPEs as Wasm traps). The machine will SIGFPE in some
;; cases when `srem` is valid (specifically -INT_MIN % -1).
function %i8(i8, i8) -> i8 {
block0(v0: i8, v1: i8):
v2 = srem.i8 v0, v1
; check: movq %rdi, %rax
; nextln: movl $$0, %edx
; nextln: srem $$rax:$$rdx, %sil
; nextln: shrq $$8, %rax
return v2
}
function %i16(i16, i16) -> i16 {
block0(v0: i16, v1: i16):
v2 = srem.i16 v0, v1
; check: movq %rdi, %rax
; nextln: movl $$0, %edx
; nextln: srem $$rax:$$rdx, %si
; nextln: movq %rdx, %rax
return v2
}
function %i32(i32, i32) -> i32 {
block0(v0: i32, v1: i32):
v2 = srem.i32 v0, v1
; check: movq %rdi, %rax
; nextln: movl $$0, %edx
; nextln: srem $$rax:$$rdx, %esi
; nextln: movq %rdx, %rax
return v2
}
function %i64(i64, i64) -> i64 {
block0(v0: i64, v1: i64):
v2 = srem.i64 v0, v1
; check: movq %rdi, %rax
; nextln: movl $$0, %edx
; nextln: srem $$rax:$$rdx, %rsi
; nextln: movq %rdx, %rax
return v2
}