Files
wasmtime/cranelift/filetests/filetests/isa/x64/udiv.clif
Alex Crichton 5c1b468648 x64: Migrate {s,u}{div,rem} to ISLE (#6008)
* x64: Add precise-output tests for div traps

This adds a suite of `*.clif` files which are intended to test the
`avoid_div_traps=true` compilation of the `{s,u}{div,rem}` instructions.

* x64: Remove conditional regalloc in `Div` instruction

Move the 8-bit `Div` logic into a dedicated `Div8` instruction to avoid
having conditionally-used registers with respect to regalloc.

* x64: Migrate non-trapping, `udiv`/`urem` to ISLE

* x64: Port checked `udiv` to ISLE

* x64: Migrate urem entirely to ISLE

* x64: Use `test` instead of `cmp` to compare-to-zero

* x64: Port `sdiv` lowering to ISLE

* x64: Port `srem` lowering to ISLE

* Tidy up regalloc behavior and fix tests

* Update docs and winch

* Review comments

* Reword again

* More refactoring test fixes

* More test fixes
2023-03-14 01:44:06 +00:00

118 lines
2.0 KiB
Plaintext

test compile precise-output
target x86_64
function %f1(i8, i8) -> i8 {
block0(v0: i8, v1: i8):
v2 = udiv v0, v1
return v2
}
; VCode:
; pushq %rbp
; movq %rsp, %rbp
; block0:
; movzbl %dil, %eax
; div %al, %sil, %al
; movq %rbp, %rsp
; popq %rbp
; ret
;
; Disassembled:
; block0: ; offset 0x0
; pushq %rbp
; movq %rsp, %rbp
; block1: ; offset 0x4
; movzbl %dil, %eax
; divb %sil ; trap: int_divz
; movq %rbp, %rsp
; popq %rbp
; retq
function %f2(i16, i16) -> i16 {
block0(v0: i16, v1: i16):
v2 = udiv v0, v1
return v2
}
; VCode:
; pushq %rbp
; movq %rsp, %rbp
; block0:
; movq %rdi, %rax
; xorq %rdx, %rdx, %rdx
; div %ax, %dx, %si, %ax, %dx
; movq %rbp, %rsp
; popq %rbp
; ret
;
; Disassembled:
; block0: ; offset 0x0
; pushq %rbp
; movq %rsp, %rbp
; block1: ; offset 0x4
; movq %rdi, %rax
; xorq %rdx, %rdx
; divw %si ; trap: int_divz
; movq %rbp, %rsp
; popq %rbp
; retq
function %f3(i32, i32) -> i32 {
block0(v0: i32, v1: i32):
v2 = udiv v0, v1
return v2
}
; VCode:
; pushq %rbp
; movq %rsp, %rbp
; block0:
; movq %rdi, %rax
; xorq %rdx, %rdx, %rdx
; div %eax, %edx, %esi, %eax, %edx
; movq %rbp, %rsp
; popq %rbp
; ret
;
; Disassembled:
; block0: ; offset 0x0
; pushq %rbp
; movq %rsp, %rbp
; block1: ; offset 0x4
; movq %rdi, %rax
; xorq %rdx, %rdx
; divl %esi ; trap: int_divz
; movq %rbp, %rsp
; popq %rbp
; retq
function %f4(i64, i64) -> i64 {
block0(v0: i64, v1: i64):
v2 = udiv v0, v1
return v2
}
; VCode:
; pushq %rbp
; movq %rsp, %rbp
; block0:
; movq %rdi, %rax
; xorq %rdx, %rdx, %rdx
; div %rax, %rdx, %rsi, %rax, %rdx
; movq %rbp, %rsp
; popq %rbp
; ret
;
; Disassembled:
; block0: ; offset 0x0
; pushq %rbp
; movq %rsp, %rbp
; block1: ; offset 0x4
; movq %rdi, %rax
; xorq %rdx, %rdx
; divq %rsi ; trap: int_divz
; movq %rbp, %rsp
; popq %rbp
; retq