blob: 034d3f114ee07b554b550f6e2dd53177287751ac [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
Tom Stellard86d12eb2014-08-01 00:32:28 +00002
3; Test that we correctly commute a sub instruction
Tom Stellard79243d92014-10-01 17:15:17 +00004; FUNC-LABEL: {{^}}sub_rev:
Tom Stellard86d12eb2014-08-01 00:32:28 +00005; SI-NOT: V_SUB_I32_e32 v{{[0-9]+}}, s
6; SI: V_SUBREV_I32_e32 v{{[0-9]+}}, s
7
8; ModuleID = 'vop-shrink.ll'
9
10define void @sub_rev(i32 addrspace(1)* %out, <4 x i32> %sgpr, i32 %cond) {
11entry:
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
15
16if: ; preds = %entry
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
20 br label %endif
21
22else: ; 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
26 br label %endif
27
28endif: ; preds = %else, %if
29 ret void
30}
31
Tom Stellard6407e1e2014-08-01 00:32:33 +000032; Test that we fold an immediate that was illegal for a 64-bit op into the
33; 32-bit op when we shrink it.
34
Tom Stellard79243d92014-10-01 17:15:17 +000035; FUNC-LABEL: {{^}}add_fold:
Tom Stellard6407e1e2014-08-01 00:32:33 +000036; SI: V_ADD_F32_e32 v{{[0-9]+}}, 0x44800000
37define void @add_fold(float addrspace(1)* %out) {
38entry:
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
43 ret void
44}
45
Tom Stellard86d12eb2014-08-01 00:32:28 +000046; Function Attrs: nounwind readnone
47declare i32 @llvm.r600.read.tidig.x() #0
48
49attributes #0 = { nounwind readnone }
50attributes #1 = { readnone }