1; RUN: llc -O3 -mtriple=armv8a-none-eabi -mattr=+fullfp16 -o - %s | FileCheck %s
2; RUN: llc -O3 -mtriple=thumbv8a-none-eabi -mattr=+fullfp16 -arm-no-restrict-it -o - %s | FileCheck %s
3
4; Require the vmul.f16 not to be predicated, because it's illegal to
5; do so with fp16 instructions
6define half @conditional_fmul_f16(half* %p) {
7; CHECK-LABEL: conditional_fmul_f16:
8; CHECK: vmul.f16
9entry:
10  %p1 = getelementptr half, half* %p, i32 1
11  %a = load half, half* %p, align 2
12  %threshold = load half, half* %p1, align 2
13  %flag = fcmp ogt half %a, %threshold
14  br i1 %flag, label %mul, label %out
15
16mul:
17  %p2 = getelementptr half, half* %p, i32 2
18  %mult = load half, half* %p2, align 2
19  %b = fmul half %a, %mult
20  br label %out
21
22out:
23  %sel = phi half [ %a, %entry ], [ %b, %mul ]
24  ret half %sel
25}
26
27; Expect that the corresponding vmul.f32 _will_ be predicated (to make
28; sure the previous test is really testing something)
29define float @conditional_fmul_f32(float* %p) {
30; CHECK-LABEL: conditional_fmul_f32:
31; CHECK: vmulgt.f32
32entry:
33  %p1 = getelementptr float, float* %p, i32 1
34  %a = load float, float* %p, align 2
35  %threshold = load float, float* %p1, align 2
36  %flag = fcmp ogt float %a, %threshold
37  br i1 %flag, label %mul, label %out
38
39mul:
40  %p2 = getelementptr float, float* %p, i32 2
41  %mult = load float, float* %p2, align 2
42  %b = fmul float %a, %mult
43  br label %out
44
45out:
46  %sel = phi float [ %a, %entry ], [ %b, %mul ]
47  ret float %sel
48}
49
50; Require the two comparisons to be done with unpredicated vcmp.f16
51; instructions (again, it is illegal to predicate them)
52define void @chained_comparisons_f16(half* %p) {
53; CHECK-LABEL: chained_comparisons_f16:
54; CHECK: vcmp.f16
55; CHECK: vcmp.f16
56entry:
57  %p1 = getelementptr half, half* %p, i32 1
58
59  %a = load half, half* %p, align 2
60  %b = load half, half* %p1, align 2
61
62  %aflag = fcmp oeq half %a, 0xH0000
63  %bflag = fcmp oeq half %b, 0xH0000
64  %flag = or i1 %aflag, %bflag
65  br i1 %flag, label %call, label %out
66
67call:
68  call void @external_function()
69  br label %out
70
71out:
72  ret void
73}
74
75; Again, do the corresponding test with 32-bit floats and check that
76; the second comparison _is_ predicated on the result of the first.
77define void @chained_comparisons_f32(float* %p) {
78; CHECK-LABEL: chained_comparisons_f32:
79; CHECK: vcmp.f32
80; CHECK: vcmpne.f32
81entry:
82  %p1 = getelementptr float, float* %p, i32 1
83
84  %a = load float, float* %p, align 2
85  %b = load float, float* %p1, align 2
86
87  %aflag = fcmp oeq float %a, 0x00000000
88  %bflag = fcmp oeq float %b, 0x00000000
89  %flag = or i1 %aflag, %bflag
90  br i1 %flag, label %call, label %out
91
92call:
93  call void @external_function()
94  br label %out
95
96out:
97  ret void
98}
99
100declare void @external_function()
101