1 ; RUN: llc -march=amdgcn < %s | FileCheck -check-prefixes=GCN,SI %s
2 ; RUN: llc -march=amdgcn -mcpu=tonga < %s | FileCheck -check-prefixes=GCN,VI %s
3 ; RUN: llc -march=amdgcn -mcpu=gfx900 < %s | FileCheck -check-prefixes=GCN,GFX9 %s
5 ; GCN-LABEL: {{^}}v_test_imin3_slt_i32:
7 define amdgpu_kernel void @v_test_imin3_slt_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) #0 {
8 %tid = call i32 @llvm.amdgcn.workitem.id.x()
9 %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
13 %a = load i32, i32 addrspace(1)* %gep0
14 %b = load i32, i32 addrspace(1)* %gep1
15 %c = load i32, i32 addrspace(1)* %gep2
16 %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
24 ; GCN-LABEL: {{^}}v_test_umin3_ult_i32:
26 define amdgpu_kernel void @v_test_umin3_ult_i32(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) #0 {
27 %tid = call i32 @llvm.amdgcn.workitem.id.x()
28 %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
32 %a = load i32, i32 addrspace(1)* %gep0
33 %b = load i32, i32 addrspace(1)* %gep1
34 %c = load i32, i32 addrspace(1)* %gep2
35 %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
43 ; GCN-LABEL: {{^}}v_test_umin_umin_umin:
46 define amdgpu_kernel void @v_test_umin_umin_umin(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) #0 {
47 %tid = call i32 @llvm.amdgcn.workitem.id.x()
48 %tid2 = mul i32 %tid, 2
49 %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
53 %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
57 %outgep0 = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
58 %outgep1 = getelementptr i32, i32 addrspace(1)* %out, i32 %tid2
60 %a = load i32, i32 addrspace(1)* %gep0
61 %b = load i32, i32 addrspace(1)* %gep1
62 %c = load i32, i32 addrspace(1)* %gep2
63 %d = load i32, i32 addrspace(1)* %gep3
65 %icmp0 = icmp slt i32 %a, %b
66 %i0 = select i1 %icmp0, i32 %a, i32 %b
68 %icmp1 = icmp slt i32 %c, %d
69 %i1 = select i1 %icmp1, i32 %c, i32 %d
71 %icmp2 = icmp slt i32 %i0, %i1
72 %i2 = select i1 %icmp2, i32 %i0, i32 %i1
74 store i32 %i2, i32 addrspace(1)* %outgep1
78 ; GCN-LABEL: {{^}}v_test_umin3_2_uses:
80 define amdgpu_kernel void @v_test_umin3_2_uses(i32 addrspace(1)* %out, i32 addrspace(1)* %aptr, i32 addrspace(1)* %bptr, i32 addrspace(1)* %cptr) #0 {
81 %tid = call i32 @llvm.amdgcn.workitem.id.x()
82 %tid2 = mul i32 %tid, 2
83 %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
87 %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
91 %outgep0 = getelementptr i32, i32 addrspace(1)* %out, i32 %tid
92 %outgep1 = getelementptr i32, i32 addrspace(1)* %out, i32 %tid2
94 %a = load i32, i32 addrspace(1)* %gep0
95 %b = load i32, i32 addrspace(1)* %gep1
96 %c = load i32, i32 addrspace(1)* %gep2
97 %d = load i32, i32 addrspace(1)* %gep3
99 %icmp0 = icmp slt i32 %a, %b
100 %i0 = select i1 %icmp0, i32 %a, i32 %b
102 %icmp1 = icmp slt i32 %c, %d
103 %i1 = select i1 %icmp1, i32 %c, i32 %d
105 %icmp2 = icmp slt i32 %i0, %c
106 %i2 = select i1 %icmp2, i32 %i0, i32 %c
108 store i32 %i2, i32 addrspace(1)* %outgep0
109 store i32 %i0, i32 addrspace(1)* %outgep1
113 ; GCN-LABEL: {{^}}v_test_imin3_slt_i16:
120 define amdgpu_kernel void @v_test_imin3_slt_i16(i16 addrspace(1)* %out, i16 addrspace(1)* %aptr, i16 addrspace(1)* %bptr, i16 addrspace(1)* %cptr) #0 {
121 %tid = call i32 @llvm.amdgcn.workitem.id.x()
122 %gep0 = getelementptr i16, i16 addrspace(1)* %aptr, i32 %tid
123 %gep1 = getelementptr i16, i16 addrspace(1)* %bptr, i32 %tid
124 %gep2 = getelementptr i16, i16 addrspace(1)* %cptr, i32 %tid
125 %outgep = getelementptr i16, i16 addrspace(1)* %out, i32 %tid
126 %a = load i16, i16 addrspace(1)* %gep0
127 %b = load i16, i16 addrspace(1)* %gep1
128 %c = load i16, i16 addrspace(1)* %gep2
129 %icmp0 = icmp slt i16 %a, %b
130 %i0 = select i1 %icmp0, i16 %a, i16 %b
131 %icmp1 = icmp slt i16 %i0, %c
132 %i1 = select i1 %icmp1, i16 %i0, i16 %c
133 store i16 %i1, i16 addrspace(1)* %outgep
137 ; GCN-LABEL: {{^}}v_test_umin3_ult_i16:
144 define amdgpu_kernel void @v_test_umin3_ult_i16(i16 addrspace(1)* %out, i16 addrspace(1)* %aptr, i16 addrspace(1)* %bptr, i16 addrspace(1)* %cptr) #0 {
145 %tid = call i32 @llvm.amdgcn.workitem.id.x()
146 %gep0 = getelementptr i16, i16 addrspace(1)* %aptr, i32 %tid
147 %gep1 = getelementptr i16, i16 addrspace(1)* %bptr, i32 %tid
148 %gep2 = getelementptr i16, i16 addrspace(1)* %cptr, i32 %tid
149 %outgep = getelementptr i16, i16 addrspace(1)* %out, i32 %tid
150 %a = load i16, i16 addrspace(1)* %gep0
151 %b = load i16, i16 addrspace(1)* %gep1
152 %c = load i16, i16 addrspace(1)* %gep2
153 %icmp0 = icmp ult i16 %a, %b
154 %i0 = select i1 %icmp0, i16 %a, i16 %b
155 %icmp1 = icmp ult i16 %i0, %c
156 %i1 = select i1 %icmp1, i16 %i0, i16 %c
157 store i16 %i1, i16 addrspace(1)* %outgep
161 declare i32 @llvm.amdgcn.workitem.id.x() #1
163 attributes #0 = { nounwind }
164 attributes #1 = { nounwind readnone speculatable }