1 ; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
3 ; Test that we correctly commute a sub instruction
5 ; SI-NOT: V_SUB_I32_e32 v{{[0-9]+}}, s
6 ; SI: V_SUBREV_I32_e32 v{{[0-9]+}}, s
8 ; ModuleID = 'vop-shrink.ll'
10 define void @sub_rev(i32 addrspace(1)* %out, <4 x i32> %sgpr, i32 %cond) {
12 %vgpr = call i32 @llvm.r600.read.tidig.x() #1
13 %tmp = icmp eq i32 %cond, 0
14 br i1 %tmp, label %if, label %else
17 %tmp1 = getelementptr i32 addrspace(1)* %out, i32 1
18 %tmp2 = extractelement <4 x i32> %sgpr, i32 1
19 store i32 %tmp2, i32 addrspace(1)* %out
22 else: ; preds = %entry
23 %tmp3 = extractelement <4 x i32> %sgpr, i32 2
24 %tmp4 = sub i32 %vgpr, %tmp3
25 store i32 %tmp4, i32 addrspace(1)* %out
28 endif: ; preds = %else, %if
32 ; Test that we fold an immediate that was illegal for a 64-bit op into the
33 ; 32-bit op when we shrink it.
35 ; FUNC-LABEL: @add_fold
36 ; SI: V_ADD_F32_e32 v{{[0-9]+}}, 0x44800000
37 define void @add_fold(float addrspace(1)* %out) {
39 %tmp = call i32 @llvm.r600.read.tidig.x()
40 %tmp1 = uitofp i32 %tmp to float
41 %tmp2 = fadd float %tmp1, 1.024000e+03
42 store float %tmp2, float addrspace(1)* %out
46 ; Function Attrs: nounwind readnone
47 declare i32 @llvm.r600.read.tidig.x() #0
49 attributes #0 = { nounwind readnone }
50 attributes #1 = { readnone }