cranelift x64: use the TZCNT instruction for Ctz when it's available;

This commit is contained in:
Benjamin Bouvier
2021-01-28 12:02:47 +01:00
parent d3acd9a283
commit 6bf6612d96
4 changed files with 53 additions and 4 deletions

View File

@@ -0,0 +1,31 @@
test compile
target x86_64 has_bmi1
feature "experimental_x64"
function %ctz(i64) -> i64 {
block0(v0: i64):
v1 = ctz v0
return v1
}
; check: pushq %rbp
; check: movq %rsp, %rbp
; check: tzcntq %rdi, %rsi
; check: movq %rsi, %rax
; check: movq %rbp, %rsp
; check: popq %rbp
; check: ret
function %ctz(i32) -> i32 {
block0(v0: i32):
v1 = ctz v0
return v1
}
; check: pushq %rbp
; check: movq %rsp, %rbp
; check: tzcntl %edi, %esi
; check: movq %rsi, %rax
; check: movq %rbp, %rsp
; check: popq %rbp
; check: ret