86 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=arm64-eabi -enable-no-nans-fp-math | FileCheck %s3 4define double @test_direct(float %in) {5; CHECK-LABEL: test_direct:6; CHECK: // %bb.0:7; CHECK-NEXT: movi d1, #00000000000000008; CHECK-NEXT: fmaxnm s0, s0, s19; CHECK-NEXT: fcvt d0, s010; CHECK-NEXT: ret11 %cmp = fcmp nnan olt float %in, 0.000000e+0012 %val = select i1 %cmp, float 0.000000e+00, float %in13 %longer = fpext float %val to double14 ret double %longer15}16 17define double @test_cross(float %in) {18; CHECK-LABEL: test_cross:19; CHECK: // %bb.0:20; CHECK-NEXT: movi d1, #000000000000000021; CHECK-NEXT: fminnm s0, s0, s122; CHECK-NEXT: fcvt d0, s023; CHECK-NEXT: ret24 %cmp = fcmp nnan ult float %in, 0.000000e+0025 %val = select i1 %cmp, float %in, float 0.000000e+0026 %longer = fpext float %val to double27 ret double %longer28}29 30; Same as previous, but with ordered comparison;31; can't be converted in safe-math mode.32define double @test_cross_fail_nan(float %in) {33; CHECK-LABEL: test_cross_fail_nan:34; CHECK: // %bb.0:35; CHECK-NEXT: movi d1, #000000000000000036; CHECK-NEXT: fminnm s0, s0, s137; CHECK-NEXT: fcvt d0, s038; CHECK-NEXT: ret39 %cmp = fcmp nnan olt float %in, 0.000000e+0040 %val = select i1 %cmp, float %in, float 0.000000e+0041 %longer = fpext float %val to double42 ret double %longer43}44 45; This isn't a min or a max, but passes the first condition for swapping the46; results. Make sure they're put back before we resort to the normal fcsel.47define float @test_cross_fail(float %lhs, float %rhs) {48; CHECK-LABEL: test_cross_fail:49; CHECK: // %bb.0:50; CHECK-NEXT: fcmp s0, s151; CHECK-NEXT: fcsel s0, s1, s0, ne52; CHECK-NEXT: ret53 %tst = fcmp nnan une float %lhs, %rhs54 %res = select i1 %tst, float %rhs, float %lhs55 ret float %res56}57 58; Make sure the transformation isn't triggered for integers59define i64 @test_integer(i64 %in) {60; CHECK-LABEL: test_integer:61; CHECK: // %bb.0:62; CHECK-NEXT: cmp x0, #063; CHECK-NEXT: csel x0, xzr, x0, mi64; CHECK-NEXT: ret65 %cmp = icmp slt i64 %in, 066 %val = select i1 %cmp, i64 0, i64 %in67 ret i64 %val68}69 70; FIXME: It'd be nice for this to create an fmin instruction!71define float @test_f16(half %in) {72; CHECK-LABEL: test_f16:73; CHECK: // %bb.0:74; CHECK-NEXT: // kill: def $h0 killed $h0 def $s075; CHECK-NEXT: fcvt s1, h076; CHECK-NEXT: movi d2, #000000000000000077; CHECK-NEXT: fcmp s1, #0.078; CHECK-NEXT: fcsel s0, s0, s2, lt79; CHECK-NEXT: fcvt s0, h080; CHECK-NEXT: ret81 %cmp = fcmp nnan ult half %in, 0.000000e+0082 %val = select i1 %cmp, half %in, half 0.000000e+0083 %longer = fpext half %val to float84 ret float %longer85}86