1; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s 2; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s 3; RUN: llc -march=r600 -mcpu=cypress -verify-machineinstrs < %s | FileCheck -check-prefix=EG -check-prefix=FUNC %s 4 5declare i32 @llvm.cttz.i32(i32, i1) nounwind readnone 6declare <2 x i32> @llvm.cttz.v2i32(<2 x i32>, i1) nounwind readnone 7declare <4 x i32> @llvm.cttz.v4i32(<4 x i32>, i1) nounwind readnone 8declare i32 @llvm.r600.read.tidig.x() nounwind readnone 9 10; FUNC-LABEL: {{^}}s_cttz_zero_undef_i32: 11; SI: s_load_dword [[VAL:s[0-9]+]], 12; SI: s_ff1_i32_b32 [[SRESULT:s[0-9]+]], [[VAL]] 13; SI: v_mov_b32_e32 [[VRESULT:v[0-9]+]], [[SRESULT]] 14; SI: buffer_store_dword [[VRESULT]], 15; SI: s_endpgm 16; EG: MEM_RAT_CACHELESS STORE_RAW [[RESULT:T[0-9]+\.[XYZW]]] 17; EG: FFBL_INT {{\*? *}}[[RESULT]] 18define amdgpu_kernel void @s_cttz_zero_undef_i32(i32 addrspace(1)* noalias %out, i32 %val) nounwind { 19 %cttz = call i32 @llvm.cttz.i32(i32 %val, i1 true) nounwind readnone 20 store i32 %cttz, i32 addrspace(1)* %out, align 4 21 ret void 22} 23 24; FUNC-LABEL: {{^}}v_cttz_zero_undef_i32: 25; SI: {{buffer|flat}}_load_dword [[VAL:v[0-9]+]], 26; SI: v_ffbl_b32_e32 [[RESULT:v[0-9]+]], [[VAL]] 27; SI: buffer_store_dword [[RESULT]], 28; SI: s_endpgm 29; EG: MEM_RAT_CACHELESS STORE_RAW [[RESULT:T[0-9]+\.[XYZW]]] 30; EG: FFBL_INT {{\*? *}}[[RESULT]] 31define amdgpu_kernel void @v_cttz_zero_undef_i32(i32 addrspace(1)* noalias %out, i32 addrspace(1)* noalias %valptr) nounwind { 32 %tid = call i32 @llvm.r600.read.tidig.x() 33 %in.gep = getelementptr i32, i32 addrspace(1)* %valptr, i32 %tid 34 %val = load i32, i32 addrspace(1)* %in.gep, align 4 35 %cttz = call i32 @llvm.cttz.i32(i32 %val, i1 true) nounwind readnone 36 store i32 %cttz, i32 addrspace(1)* %out, align 4 37 ret void 38} 39 40; FUNC-LABEL: {{^}}v_cttz_zero_undef_v2i32: 41; SI: {{buffer|flat}}_load_dwordx2 42; SI: v_ffbl_b32_e32 43; SI: v_ffbl_b32_e32 44; SI: buffer_store_dwordx2 45; SI: s_endpgm 46; EG: MEM_RAT_CACHELESS STORE_RAW [[RESULT:T[0-9]+]]{{\.[XYZW]}} 47; EG: FFBL_INT {{\*? *}}[[RESULT]] 48; EG: FFBL_INT {{\*? *}}[[RESULT]] 49define amdgpu_kernel void @v_cttz_zero_undef_v2i32(<2 x i32> addrspace(1)* noalias %out, <2 x i32> addrspace(1)* noalias %valptr) nounwind { 50 %tid = call i32 @llvm.r600.read.tidig.x() 51 %in.gep = getelementptr <2 x i32>, <2 x i32> addrspace(1)* %valptr, i32 %tid 52 %val = load <2 x i32>, <2 x i32> addrspace(1)* %in.gep, align 8 53 %cttz = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> %val, i1 true) nounwind readnone 54 store <2 x i32> %cttz, <2 x i32> addrspace(1)* %out, align 8 55 ret void 56} 57 58; FUNC-LABEL: {{^}}v_cttz_zero_undef_v4i32: 59; SI: {{buffer|flat}}_load_dwordx4 60; SI: v_ffbl_b32_e32 61; SI: v_ffbl_b32_e32 62; SI: v_ffbl_b32_e32 63; SI: v_ffbl_b32_e32 64; SI: buffer_store_dwordx4 65; SI: s_endpgm 66; EG: MEM_RAT_CACHELESS STORE_RAW [[RESULT:T[0-9]+]]{{\.[XYZW]}} 67; EG: FFBL_INT {{\*? *}}[[RESULT]] 68; EG: FFBL_INT {{\*? *}}[[RESULT]] 69; EG: FFBL_INT {{\*? *}}[[RESULT]] 70; EG: FFBL_INT {{\*? *}}[[RESULT]] 71define amdgpu_kernel void @v_cttz_zero_undef_v4i32(<4 x i32> addrspace(1)* noalias %out, <4 x i32> addrspace(1)* noalias %valptr) nounwind { 72 %tid = call i32 @llvm.r600.read.tidig.x() 73 %in.gep = getelementptr <4 x i32>, <4 x i32> addrspace(1)* %valptr, i32 %tid 74 %val = load <4 x i32>, <4 x i32> addrspace(1)* %in.gep, align 16 75 %cttz = call <4 x i32> @llvm.cttz.v4i32(<4 x i32> %val, i1 true) nounwind readnone 76 store <4 x i32> %cttz, <4 x i32> addrspace(1)* %out, align 16 77 ret void 78} 79