[WinEH] Add some test cases I forgot to add to previous commits
[oota-llvm.git] / test / CodeGen / AArch64 / arm64-fmax.ll
1 ; RUN: llc -march=arm64 -enable-no-nans-fp-math < %s | FileCheck %s
2 ; RUN: llc -march=arm64 < %s | FileCheck %s --check-prefix=CHECK-SAFE
3
4 define double @test_direct(float %in) {
5 ; CHECK-LABEL: test_direct:
6 ; CHECK-SAFE-LABEL: test_direct:
7   %cmp = fcmp olt float %in, 0.000000e+00
8   %longer = fpext float %in to double
9   %val = select i1 %cmp, double 0.000000e+00, double %longer
10   ret double %val
11
12 ; CHECK: fmax
13 ; CHECK-SAFE: fmax
14 }
15
16 define double @test_cross(float %in) {
17 ; CHECK-LABEL: test_cross:
18 ; CHECK-SAFE-LABEL: test_cross:
19   %cmp = fcmp ult float %in, 0.000000e+00
20   %longer = fpext float %in to double
21   %val = select i1 %cmp, double %longer, double 0.000000e+00
22   ret double %val
23
24 ; CHECK: fmin
25 ; CHECK-SAFE: fmin
26 }
27
28 ; Same as previous, but with ordered comparison;
29 ; can't be converted in safe-math mode.
30 define double @test_cross_fail_nan(float %in) {
31 ; CHECK-LABEL: test_cross_fail_nan:
32 ; CHECK-SAFE-LABEL: test_cross_fail_nan:
33   %cmp = fcmp olt float %in, 0.000000e+00
34   %longer = fpext float %in to double
35   %val = select i1 %cmp, double %longer, double 0.000000e+00
36   ret double %val
37
38 ; CHECK: fmin
39 ; CHECK-SAFE: fcsel d0, d1, d0, mi
40 }
41
42 ; This isn't a min or a max, but passes the first condition for swapping the
43 ; results. Make sure they're put back before we resort to the normal fcsel.
44 define float @test_cross_fail(float %lhs, float %rhs) {
45 ; CHECK-LABEL: test_cross_fail:
46 ; CHECK-SAFE-LABEL: test_cross_fail:
47   %tst = fcmp une float %lhs, %rhs
48   %res = select i1 %tst, float %rhs, float %lhs
49   ret float %res
50
51   ; The register allocator would have to decide to be deliberately obtuse before
52   ; other register were used.
53 ; CHECK: fcsel s0, s1, s0, ne
54 ; CHECK-SAFE: fcsel s0, s1, s0, ne
55 }
56
57 ; Make sure the transformation isn't triggered for integers
58 define i64 @test_integer(i64  %in) {
59   %cmp = icmp slt i64 %in, 0
60   %val = select i1 %cmp, i64 0, i64 %in
61   ret i64 %val
62 }