cranelift x64: use the LZCNT instruction for Clz when it's available;
This commit is contained in:
31
cranelift/filetests/filetests/isa/x64/clz-lzcnt.clif
Normal file
31
cranelift/filetests/filetests/isa/x64/clz-lzcnt.clif
Normal file
@@ -0,0 +1,31 @@
|
||||
test compile
|
||||
target x86_64 has_lzcnt
|
||||
feature "experimental_x64"
|
||||
|
||||
function %clz(i64) -> i64 {
|
||||
block0(v0: i64):
|
||||
v1 = clz v0
|
||||
return v1
|
||||
}
|
||||
|
||||
; check: pushq %rbp
|
||||
; check: movq %rsp, %rbp
|
||||
; check: lzcntq %rdi, %rsi
|
||||
; check: movq %rsi, %rax
|
||||
; check: movq %rbp, %rsp
|
||||
; check: popq %rbp
|
||||
; check: ret
|
||||
|
||||
function %clz(i32) -> i32 {
|
||||
block0(v0: i32):
|
||||
v1 = clz v0
|
||||
return v1
|
||||
}
|
||||
|
||||
; check: pushq %rbp
|
||||
; check: movq %rsp, %rbp
|
||||
; check: lzcntl %edi, %esi
|
||||
; check: movq %rsi, %rax
|
||||
; check: movq %rbp, %rsp
|
||||
; check: popq %rbp
|
||||
; check: ret
|
||||
Reference in New Issue
Block a user