blob: 728479ad9f62fd03cb50106705f03fbf969e234d [file] [log] [blame]
Matt Arsenault9c47dd52016-02-11 06:02:01 +00001; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +00002
Matt Arsenault9c47dd52016-02-11 06:02:01 +00003declare i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +00004
5; FUNC-LABEL: @v_test_imin3_slt_i32
6; SI: v_min3_i32
7define void @v_test_imin3_slt_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) nounwind {
Matt Arsenault9c47dd52016-02-11 06:02:01 +00008 %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
David Blaikie79e6c742015-02-27 19:29:02 +00009 %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
10 %gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
11 %gep2 = getelementptr i32, i32 addrspace(1)* %cptr, i32 %tid
12 %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
David Blaikiea79ac142015-02-27 21:17:42 +000013 %a = load i32, i32 addrspace(1)* %gep0, align 4
14 %b = load i32, i32 addrspace(1)* %gep1, align 4
15 %c = load i32, i32 addrspace(1)* %gep2, align 4
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000016 %icmp0 = icmp slt i32 %a, %b
17 %i0 = select i1 %icmp0, i32 %a, i32 %b
18 %icmp1 = icmp slt i32 %i0, %c
19 %i1 = select i1 %icmp1, i32 %i0, i32 %c
20 store i32 %i1, i32 addrspace(1)* %outgep, align 4
21 ret void
22}
23
24; FUNC-LABEL: @v_test_umin3_ult_i32
25; SI: v_min3_u32
26define void @v_test_umin3_ult_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) nounwind {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000027 %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
David Blaikie79e6c742015-02-27 19:29:02 +000028 %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
29 %gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
30 %gep2 = getelementptr i32, i32 addrspace(1)* %cptr, i32 %tid
31 %outgep = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
David Blaikiea79ac142015-02-27 21:17:42 +000032 %a = load i32, i32 addrspace(1)* %gep0, align 4
33 %b = load i32, i32 addrspace(1)* %gep1, align 4
34 %c = load i32, i32 addrspace(1)* %gep2, align 4
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000035 %icmp0 = icmp ult i32 %a, %b
36 %i0 = select i1 %icmp0, i32 %a, i32 %b
37 %icmp1 = icmp ult i32 %i0, %c
38 %i1 = select i1 %icmp1, i32 %i0, i32 %c
39 store i32 %i1, i32 addrspace(1)* %outgep, align 4
40 ret void
41}
42
43; FUNC-LABEL: @v_test_umin_umin_umin
44; SI: v_min_i32
45; SI: v_min3_i32
46define void @v_test_umin_umin_umin(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) nounwind {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000047 %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000048 %tid2 = mul i32 %tid, 2
David Blaikie79e6c742015-02-27 19:29:02 +000049 %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
50 %gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
51 %gep2 = getelementptr i32, i32 addrspace(1)* %cptr, i32 %tid
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000052
David Blaikie79e6c742015-02-27 19:29:02 +000053 %gep3 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid2
54 %gep4 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid2
55 %gep5 = getelementptr i32, i32 addrspace(1)* %cptr, i32 %tid2
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000056
David Blaikie79e6c742015-02-27 19:29:02 +000057 %outgep0 = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
58 %outgep1 = getelementptr i32, i32 addrspace(1)* %out, i32 %tid2
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000059
David Blaikiea79ac142015-02-27 21:17:42 +000060 %a = load i32, i32 addrspace(1)* %gep0, align 4
61 %b = load i32, i32 addrspace(1)* %gep1, align 4
62 %c = load i32, i32 addrspace(1)* %gep2, align 4
63 %d = load i32, i32 addrspace(1)* %gep3, align 4
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000064
65 %icmp0 = icmp slt i32 %a, %b
66 %i0 = select i1 %icmp0, i32 %a, i32 %b
67
68 %icmp1 = icmp slt i32 %c, %d
69 %i1 = select i1 %icmp1, i32 %c, i32 %d
70
71 %icmp2 = icmp slt i32 %i0, %i1
72 %i2 = select i1 %icmp2, i32 %i0, i32 %i1
73
74 store i32 %i2, i32 addrspace(1)* %outgep1, align 4
75 ret void
76}
77
78; FUNC-LABEL: @v_test_umin3_2_uses
79; SI-NOT: v_min3
80define void @v_test_umin3_2_uses(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) nounwind {
Matt Arsenault9c47dd52016-02-11 06:02:01 +000081 %tid = call i32 @llvm.amdgcn.workitem.id.x() nounwind readnone
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000082 %tid2 = mul i32 %tid, 2
David Blaikie79e6c742015-02-27 19:29:02 +000083 %gep0 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid
84 %gep1 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid
85 %gep2 = getelementptr i32, i32 addrspace(1)* %cptr, i32 %tid
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000086
David Blaikie79e6c742015-02-27 19:29:02 +000087 %gep3 = getelementptr i32, i32 addrspace(1)* %aptr, i32 %tid2
88 %gep4 = getelementptr i32, i32 addrspace(1)* %bptr, i32 %tid2
89 %gep5 = getelementptr i32, i32 addrspace(1)* %cptr, i32 %tid2
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000090
David Blaikie79e6c742015-02-27 19:29:02 +000091 %outgep0 = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
92 %outgep1 = getelementptr i32, i32 addrspace(1)* %out, i32 %tid2
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000093
David Blaikiea79ac142015-02-27 21:17:42 +000094 %a = load i32, i32 addrspace(1)* %gep0, align 4
95 %b = load i32, i32 addrspace(1)* %gep1, align 4
96 %c = load i32, i32 addrspace(1)* %gep2, align 4
97 %d = load i32, i32 addrspace(1)* %gep3, align 4
Matt Arsenaultcc3c2b32014-11-14 20:08:52 +000098
99 %icmp0 = icmp slt i32 %a, %b
100 %i0 = select i1 %icmp0, i32 %a, i32 %b
101
102 %icmp1 = icmp slt i32 %c, %d
103 %i1 = select i1 %icmp1, i32 %c, i32 %d
104
105 %icmp2 = icmp slt i32 %i0, %c
106 %i2 = select i1 %icmp2, i32 %i0, i32 %c
107
108 store i32 %i2, i32 addrspace(1)* %outgep0, align 4
109 store i32 %i0, i32 addrspace(1)* %outgep1, align 4
110 ret void
111}