1 ; RUN: llc -march=amdgcn -stop-after=amdgpu-isel < %s | FileCheck -check-prefix=GCN %s
3 ; GCN-LABEL: name: s_ctlz_i32
5 define amdgpu_kernel void @s_ctlz_i32(ptr addrspace(1) noalias %out, i32 %val) nounwind {
6 %ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 false) nounwind readnone
7 store i32 %ctlz, ptr addrspace(1) %out, align 4
10 ; GCN-LABEL: name: v_ctlz_i32
12 define amdgpu_kernel void @v_ctlz_i32(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %valptr) nounwind {
13 %tid = call i32 @llvm.amdgcn.workitem.id.x()
14 %in.gep = getelementptr i32, ptr addrspace(1) %valptr, i32 %tid
15 %val = load i32, ptr addrspace(1) %in.gep, align 4
16 %ctlz = call i32 @llvm.ctlz.i32(i32 %val, i1 false) nounwind readnone
17 store i32 %ctlz, ptr addrspace(1) %out, align 4
21 ; GCN-LABEL: name: s_cttz_i32
23 define amdgpu_kernel void @s_cttz_i32(ptr addrspace(1) noalias %out, i32 %val) nounwind {
24 %cttz = call i32 @llvm.cttz.i32(i32 %val, i1 false) nounwind readnone
25 store i32 %cttz, ptr addrspace(1) %out, align 4
29 ; GCN-LABEL: name: v_cttz_i32
31 define amdgpu_kernel void @v_cttz_i32(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %valptr) nounwind {
32 %tid = call i32 @llvm.amdgcn.workitem.id.x()
33 %in.gep = getelementptr i32, ptr addrspace(1) %valptr, i32 %tid
34 %val = load i32, ptr addrspace(1) %in.gep, align 4
35 %cttz = call i32 @llvm.cttz.i32(i32 %val, i1 false) nounwind readnone
36 store i32 %cttz, ptr addrspace(1) %out, align 4
40 ; GCN-LABEL: name: s_flbit
42 define amdgpu_kernel void @s_flbit(ptr addrspace(1) noalias %out, i32 %val) #0 {
43 %r = call i32 @llvm.amdgcn.sffbh.i32(i32 %val)
44 store i32 %r, ptr addrspace(1) %out, align 4
48 ; GCN-LABEL: name: v_flbit
50 define amdgpu_kernel void @v_flbit(ptr addrspace(1) noalias %out, ptr addrspace(1) noalias %valptr) #0 {
51 %tid = call i32 @llvm.amdgcn.workitem.id.x()
52 %in.gep = getelementptr i32, ptr addrspace(1) %valptr, i32 %tid
53 %val = load i32, ptr addrspace(1) %in.gep, align 4
54 %r = call i32 @llvm.amdgcn.sffbh.i32(i32 %val)
55 store i32 %r, ptr addrspace(1) %out, align 4
60 declare i32 @llvm.ctlz.i32(i32, i1) nounwind readnone
61 declare i32 @llvm.cttz.i32(i32, i1) nounwind readnone
62 declare i32 @llvm.amdgcn.sffbh.i32(i32)
63 declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone