1; RUN: llc -march=amdgcn < %s | FileCheck -check-prefix=SI -check-prefix=FUNC %s
2
3declare i32 @llvm.amdgcn.workitem.id.x() #1
4
5; FUNC-LABEL: @test_fmin_legacy_f64
6define void @test_fmin_legacy_f64(<4 x double> addrspace(1)* %out, <4 x double> inreg %reg0) #0 {
7   %r0 = extractelement <4 x double> %reg0, i32 0
8   %r1 = extractelement <4 x double> %reg0, i32 1
9   %r2 = fcmp uge double %r0, %r1
10   %r3 = select i1 %r2, double %r1, double %r0
11   %vec = insertelement <4 x double> undef, double %r3, i32 0
12   store <4 x double> %vec, <4 x double> addrspace(1)* %out, align 16
13   ret void
14}
15
16; FUNC-LABEL: @test_fmin_legacy_ule_f64
17define void @test_fmin_legacy_ule_f64(double addrspace(1)* %out, double addrspace(1)* %in) #0 {
18  %tid = call i32 @llvm.amdgcn.workitem.id.x() #1
19  %gep.0 = getelementptr double, double addrspace(1)* %in, i32 %tid
20  %gep.1 = getelementptr double, double addrspace(1)* %gep.0, i32 1
21
22  %a = load double, double addrspace(1)* %gep.0, align 8
23  %b = load double, double addrspace(1)* %gep.1, align 8
24
25  %cmp = fcmp ule double %a, %b
26  %val = select i1 %cmp, double %a, double %b
27  store double %val, double addrspace(1)* %out, align 8
28  ret void
29}
30
31; FUNC-LABEL: @test_fmin_legacy_ole_f64
32define void @test_fmin_legacy_ole_f64(double addrspace(1)* %out, double addrspace(1)* %in) #0 {
33  %tid = call i32 @llvm.amdgcn.workitem.id.x() #1
34  %gep.0 = getelementptr double, double addrspace(1)* %in, i32 %tid
35  %gep.1 = getelementptr double, double addrspace(1)* %gep.0, i32 1
36
37  %a = load double, double addrspace(1)* %gep.0, align 8
38  %b = load double, double addrspace(1)* %gep.1, align 8
39
40  %cmp = fcmp ole double %a, %b
41  %val = select i1 %cmp, double %a, double %b
42  store double %val, double addrspace(1)* %out, align 8
43  ret void
44}
45
46; FUNC-LABEL: @test_fmin_legacy_olt_f64
47define void @test_fmin_legacy_olt_f64(double addrspace(1)* %out, double addrspace(1)* %in) #0 {
48  %tid = call i32 @llvm.amdgcn.workitem.id.x() #1
49  %gep.0 = getelementptr double, double addrspace(1)* %in, i32 %tid
50  %gep.1 = getelementptr double, double addrspace(1)* %gep.0, i32 1
51
52  %a = load double, double addrspace(1)* %gep.0, align 8
53  %b = load double, double addrspace(1)* %gep.1, align 8
54
55  %cmp = fcmp olt double %a, %b
56  %val = select i1 %cmp, double %a, double %b
57  store double %val, double addrspace(1)* %out, align 8
58  ret void
59}
60
61; FUNC-LABEL: @test_fmin_legacy_ult_f64
62define void @test_fmin_legacy_ult_f64(double addrspace(1)* %out, double addrspace(1)* %in) #0 {
63  %tid = call i32 @llvm.amdgcn.workitem.id.x() #1
64  %gep.0 = getelementptr double, double addrspace(1)* %in, i32 %tid
65  %gep.1 = getelementptr double, double addrspace(1)* %gep.0, i32 1
66
67  %a = load double, double addrspace(1)* %gep.0, align 8
68  %b = load double, double addrspace(1)* %gep.1, align 8
69
70  %cmp = fcmp ult double %a, %b
71  %val = select i1 %cmp, double %a, double %b
72  store double %val, double addrspace(1)* %out, align 8
73  ret void
74}
75
76attributes #0 = { nounwind }
77attributes #1 = { nounwind readnone }
78