1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=arm64-eabi -enable-no-nans-fp-math | FileCheck %s
4 define double @test_direct(float %in) {
5 ; CHECK-LABEL: test_direct:
7 ; CHECK-NEXT: movi d1, #0000000000000000
8 ; CHECK-NEXT: fmaxnm s0, s0, s1
9 ; CHECK-NEXT: fcvt d0, s0
11 %cmp = fcmp nnan olt float %in, 0.000000e+00
12 %val = select i1 %cmp, float 0.000000e+00, float %in
13 %longer = fpext float %val to double
17 define double @test_cross(float %in) {
18 ; CHECK-LABEL: test_cross:
20 ; CHECK-NEXT: movi d1, #0000000000000000
21 ; CHECK-NEXT: fminnm s0, s0, s1
22 ; CHECK-NEXT: fcvt d0, s0
24 %cmp = fcmp nnan ult float %in, 0.000000e+00
25 %val = select i1 %cmp, float %in, float 0.000000e+00
26 %longer = fpext float %val to double
30 ; Same as previous, but with ordered comparison;
31 ; can't be converted in safe-math mode.
32 define double @test_cross_fail_nan(float %in) {
33 ; CHECK-LABEL: test_cross_fail_nan:
35 ; CHECK-NEXT: movi d1, #0000000000000000
36 ; CHECK-NEXT: fminnm s0, s0, s1
37 ; CHECK-NEXT: fcvt d0, s0
39 %cmp = fcmp nnan olt float %in, 0.000000e+00
40 %val = select i1 %cmp, float %in, float 0.000000e+00
41 %longer = fpext float %val to double
45 ; This isn't a min or a max, but passes the first condition for swapping the
46 ; results. Make sure they're put back before we resort to the normal fcsel.
47 define float @test_cross_fail(float %lhs, float %rhs) {
48 ; CHECK-LABEL: test_cross_fail:
50 ; CHECK-NEXT: fcmp s0, s1
51 ; CHECK-NEXT: fcsel s0, s1, s0, ne
53 %tst = fcmp nnan une float %lhs, %rhs
54 %res = select i1 %tst, float %rhs, float %lhs
58 ; Make sure the transformation isn't triggered for integers
59 define i64 @test_integer(i64 %in) {
60 ; CHECK-LABEL: test_integer:
62 ; CHECK-NEXT: cmp x0, #0
63 ; CHECK-NEXT: csel x0, xzr, x0, lt
65 %cmp = icmp slt i64 %in, 0
66 %val = select i1 %cmp, i64 0, i64 %in
70 ; FIXME: It'd be nice for this to create an fmin instruction!
71 define float @test_f16(half %in) {
72 ; CHECK-LABEL: test_f16:
74 ; CHECK-NEXT: // kill: def $h0 killed $h0 def $s0
75 ; CHECK-NEXT: fcvt s1, h0
76 ; CHECK-NEXT: movi d2, #0000000000000000
77 ; CHECK-NEXT: fcmp s1, #0.0
78 ; CHECK-NEXT: fcsel s0, s0, s2, lt
79 ; CHECK-NEXT: fcvt s0, h0
81 %cmp = fcmp nnan ult half %in, 0.000000e+00
82 %val = select i1 %cmp, half %in, half 0.000000e+00
83 %longer = fpext half %val to float