blob: ae8ec58270c1eeb67680684937bd728472a13649 [file] [log] [blame]
Matt Arsenault9c47dd52016-02-11 06:02:01 +00001; RUN: llc -march=amdgcn -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Tom Stellard86d12eb2014-08-01 00:32:28 +00003
4; Test that we correctly commute a sub instruction
Tom Stellard79243d92014-10-01 17:15:17 +00005; FUNC-LABEL: {{^}}sub_rev:
Matt Arsenaulte4d0c142015-08-29 07:16:50 +00006; SI-NOT: v_sub_i32_e32 v{{[0-9]+}}, vcc, s
7; SI: v_subrev_i32_e32 v{{[0-9]+}}, vcc, s
Tom Stellard86d12eb2014-08-01 00:32:28 +00008
9; ModuleID = 'vop-shrink.ll'
10
11define void @sub_rev(i32 addrspace(1)* %out, <4 x i32> %sgpr, i32 %cond) {
12entry:
Matt Arsenault9c47dd52016-02-11 06:02:01 +000013 %vgpr = call i32 @llvm.amdgcn.workitem.id.x() #1
Tom Stellard86d12eb2014-08-01 00:32:28 +000014 %tmp = icmp eq i32 %cond, 0
15 br i1 %tmp, label %if, label %else
16
17if: ; preds = %entry
David Blaikie79e6c742015-02-27 19:29:02 +000018 %tmp1 = getelementptr i32, i32 addrspace(1)* %out, i32 1
Tom Stellard86d12eb2014-08-01 00:32:28 +000019 %tmp2 = extractelement <4 x i32> %sgpr, i32 1
20 store i32 %tmp2, i32 addrspace(1)* %out
21 br label %endif
22
23else: ; preds = %entry
24 %tmp3 = extractelement <4 x i32> %sgpr, i32 2
25 %tmp4 = sub i32 %vgpr, %tmp3
26 store i32 %tmp4, i32 addrspace(1)* %out
27 br label %endif
28
29endif: ; preds = %else, %if
30 ret void
31}
32
Tom Stellard6407e1e2014-08-01 00:32:33 +000033; Test that we fold an immediate that was illegal for a 64-bit op into the
34; 32-bit op when we shrink it.
35
Tom Stellard79243d92014-10-01 17:15:17 +000036; FUNC-LABEL: {{^}}add_fold:
Tom Stellard326d6ec2014-11-05 14:50:53 +000037; SI: v_add_f32_e32 v{{[0-9]+}}, 0x44800000
Tom Stellard6407e1e2014-08-01 00:32:33 +000038define void @add_fold(float addrspace(1)* %out) {
39entry:
Matt Arsenault9c47dd52016-02-11 06:02:01 +000040 %tmp = call i32 @llvm.amdgcn.workitem.id.x()
Tom Stellard6407e1e2014-08-01 00:32:33 +000041 %tmp1 = uitofp i32 %tmp to float
42 %tmp2 = fadd float %tmp1, 1.024000e+03
43 store float %tmp2, float addrspace(1)* %out
44 ret void
45}
46
Tom Stellard86d12eb2014-08-01 00:32:28 +000047; Function Attrs: nounwind readnone
Matt Arsenault9c47dd52016-02-11 06:02:01 +000048declare i32 @llvm.amdgcn.workitem.id.x() #0
Tom Stellard86d12eb2014-08-01 00:32:28 +000049
50attributes #0 = { nounwind readnone }
51attributes #1 = { readnone }