blob: f8bc2b4f78f2b95b0608239f7b5c61579b861e0e [file] [log] [blame]
Tom Stellard86d12eb2014-08-01 00:32:28 +00001; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs< %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2; XXX: This testis for a bug in the SIShrinkInstruction pass and it will be
3; relevant once we are selecting 64-bit instructions. We are
4; currently selecting mostly 32-bit instruction, so the
5; SIShrinkInstructions pass isn't doing much.
6; XFAIL: *
7
8; Test that we correctly commute a sub instruction
9; FUNC-LABEL: @sub_rev
10; SI-NOT: V_SUB_I32_e32 v{{[0-9]+}}, s
11; SI: V_SUBREV_I32_e32 v{{[0-9]+}}, s
12
13; ModuleID = 'vop-shrink.ll'
14
15define void @sub_rev(i32 addrspace(1)* %out, <4 x i32> %sgpr, i32 %cond) {
16entry:
17 %vgpr = call i32 @llvm.r600.read.tidig.x() #1
18 %tmp = icmp eq i32 %cond, 0
19 br i1 %tmp, label %if, label %else
20
21if: ; preds = %entry
22 %tmp1 = getelementptr i32 addrspace(1)* %out, i32 1
23 %tmp2 = extractelement <4 x i32> %sgpr, i32 1
24 store i32 %tmp2, i32 addrspace(1)* %out
25 br label %endif
26
27else: ; preds = %entry
28 %tmp3 = extractelement <4 x i32> %sgpr, i32 2
29 %tmp4 = sub i32 %vgpr, %tmp3
30 store i32 %tmp4, i32 addrspace(1)* %out
31 br label %endif
32
33endif: ; preds = %else, %if
34 ret void
35}
36
Tom Stellard6407e1e2014-08-01 00:32:33 +000037; Test that we fold an immediate that was illegal for a 64-bit op into the
38; 32-bit op when we shrink it.
39
40; FUNC-LABEL: @add_fold
41; SI: V_ADD_F32_e32 v{{[0-9]+}}, 0x44800000
42define void @add_fold(float addrspace(1)* %out) {
43entry:
44 %tmp = call i32 @llvm.r600.read.tidig.x()
45 %tmp1 = uitofp i32 %tmp to float
46 %tmp2 = fadd float %tmp1, 1.024000e+03
47 store float %tmp2, float addrspace(1)* %out
48 ret void
49}
50
Tom Stellard86d12eb2014-08-01 00:32:28 +000051; Function Attrs: nounwind readnone
52declare i32 @llvm.r600.read.tidig.x() #0
53
54attributes #0 = { nounwind readnone }
55attributes #1 = { readnone }