1; RUN: llc -march=amdgcn -verify-machineinstrs -amdgpu-scalar-ir-passes=false < %s | FileCheck -check-prefix=GCN -check-prefix=SICIVI -check-prefix=SI %s 2; RUN: llc -march=amdgcn -mcpu=tonga -mattr=-flat-for-global -verify-machineinstrs -amdgpu-scalar-ir-passes=false < %s | FileCheck -check-prefix=GCN -check-prefix=SICIVI -check-prefix=VI %s 3; RUN: llc -march=amdgcn -mcpu=gfx900 -mattr=-flat-for-global -verify-machineinstrs -amdgpu-scalar-ir-passes=false < %s | FileCheck -check-prefix=GCN -check-prefix=GFX9 %s 4 5; These tests are split out from umed3.ll and smed3.ll and use the 6; -amdgpu-scalar-ir-passes=false flag, because InstSimplify would constant 7; fold these functions otherwise. 8 9declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone 10 11; GCN-LABEL: {{^}}v_test_umed3_r_i_i_constant_order_i32: 12; GCN: v_max_u32_e32 v{{[0-9]+}}, 17, v{{[0-9]+}} 13; GCN: v_min_u32_e32 v{{[0-9]+}}, 12, v{{[0-9]+}} 14define amdgpu_kernel void @v_test_umed3_r_i_i_constant_order_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) #1 { 15 %tid = call i32 @llvm.amdgcn.workitem.id.x() 16 %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid 17 %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid 18 %a = load i32, i32 addrspace(1)* %gep0 19 20 %icmp0 = icmp ugt i32 %a, 17 21 %i0 = select i1 %icmp0, i32 %a, i32 17 22 23 %icmp1 = icmp ult i32 %i0, 12 24 %i1 = select i1 %icmp1, i32 %i0, i32 12 25 26 store i32 %i1, i32 addrspace(1)* %outgep 27 ret void 28} 29 30; GCN-LABEL: {{^}}v_test_smed3_r_i_i_constant_order_i32: 31; GCN: v_max_i32_e32 v{{[0-9]+}}, 17, v{{[0-9]+}} 32; GCN: v_min_i32_e32 v{{[0-9]+}}, 12, v{{[0-9]+}} 33define amdgpu_kernel void @v_test_smed3_r_i_i_constant_order_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr) #1 { 34 %tid = call i32 @llvm.amdgcn.workitem.id.x() 35 %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid 36 %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid 37 %a = load i32, i32 addrspace(1)* %gep0 38 39 %icmp0 = icmp sgt i32 %a, 17 40 %i0 = select i1 %icmp0, i32 %a, i32 17 41 42 %icmp1 = icmp slt i32 %i0, 12 43 %i1 = select i1 %icmp1, i32 %i0, i32 12 44 45 store i32 %i1, i32 addrspace(1)* %outgep 46 ret void 47} 48 49