1 ; RUN: llc -mtriple=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2 ; RUN: llc -mtriple=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
4 ; Test that we correctly commute a sub instruction
5 ; FUNC-LABEL: {{^}}sub_rev:
6 ; SI-NOT: v_sub_i32_e32 v{{[0-9]+}}, vcc, s
7 ; SI: v_subrev_{{[iu]}}32_e32 v{{[0-9]+}}, vcc, s
9 ; ModuleID = 'vop-shrink.ll'
11 define amdgpu_kernel void @sub_rev(ptr addrspace(1) %out, <4 x i32> %sgpr, i32 %cond) {
13 %vgpr = call i32 @llvm.amdgcn.workitem.id.x() #1
14 %tmp = icmp eq i32 %cond, 0
15 br i1 %tmp, label %if, label %else
18 %tmp1 = getelementptr i32, ptr addrspace(1) %out, i32 1
19 %tmp2 = extractelement <4 x i32> %sgpr, i32 1
20 store i32 %tmp2, ptr addrspace(1) %out
23 else: ; preds = %entry
24 %tmp3 = extractelement <4 x i32> %sgpr, i32 2
25 %tmp4 = sub i32 %vgpr, %tmp3
26 store i32 %tmp4, ptr addrspace(1) %out
29 endif: ; preds = %else, %if
33 ; Test that we fold an immediate that was illegal for a 64-bit op into the
34 ; 32-bit op when we shrink it.
36 ; FUNC-LABEL: {{^}}add_fold:
37 ; SI: v_add_f32_e32 v{{[0-9]+}}, 0x44800000
38 define amdgpu_kernel void @add_fold(ptr addrspace(1) %out) {
40 %tmp = call i32 @llvm.amdgcn.workitem.id.x()
41 %tmp1 = uitofp i32 %tmp to float
42 %tmp2 = fadd float %tmp1, 1.024000e+03
43 store float %tmp2, ptr addrspace(1) %out
47 ; Function Attrs: nounwind readnone
48 declare i32 @llvm.amdgcn.workitem.id.x() #0
50 attributes #0 = { nounwind readnone }
51 attributes #1 = { readnone }