; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 6
; RUN: llc < %s -mtriple=aarch64 -mattr=+neon | FileCheck %s --check-prefixes=CHECK,CHECK-SD
; RUN: llc < %s -mtriple=aarch64 -mattr=+neon -global-isel | FileCheck %s --check-prefixes=CHECK,CHECK-GI

define i16 @testmhhs(half %x) {
; CHECK-SD-LABEL: testmhhs:
; CHECK-SD:       // %bb.0: // %entry
; CHECK-SD-NEXT:    fcvt s0, h0
; CHECK-SD-NEXT:    fcvtas w0, s0
; CHECK-SD-NEXT:    ret
;
; CHECK-GI-LABEL: testmhhs:
; CHECK-GI:       // %bb.0: // %entry
; CHECK-GI-NEXT:    fcvt s0, h0
; CHECK-GI-NEXT:    fcvtas x0, s0
; CHECK-GI-NEXT:    // kill: def $w0 killed $w0 killed $x0
; CHECK-GI-NEXT:    ret
entry:
  %0 = tail call i32 @llvm.lround.i32.f16(half %x)
  %conv = trunc i32 %0 to i16
  ret i16 %conv
}

define i32 @testmhws(half %x) {
; CHECK-SD-LABEL: testmhws:
; CHECK-SD:       // %bb.0: // %entry
; CHECK-SD-NEXT:    fcvt s0, h0
; CHECK-SD-NEXT:    fcvtas w0, s0
; CHECK-SD-NEXT:    ret
;
; CHECK-GI-LABEL: testmhws:
; CHECK-GI:       // %bb.0: // %entry
; CHECK-GI-NEXT:    fcvt s0, h0
; CHECK-GI-NEXT:    fcvtas x0, s0
; CHECK-GI-NEXT:    // kill: def $w0 killed $w0 killed $x0
; CHECK-GI-NEXT:    ret
entry:
  %0 = tail call i32 @llvm.lround.i32.f16(half %x)
  ret i32 %0
}

define i64 @testmhxs(half %x) {
; CHECK-SD-LABEL: testmhxs:
; CHECK-SD:       // %bb.0: // %entry
; CHECK-SD-NEXT:    fcvt s0, h0
; CHECK-SD-NEXT:    fcvtas w8, s0
; CHECK-SD-NEXT:    sxtw x0, w8
; CHECK-SD-NEXT:    ret
;
; CHECK-GI-LABEL: testmhxs:
; CHECK-GI:       // %bb.0: // %entry
; CHECK-GI-NEXT:    fcvt s0, h0
; CHECK-GI-NEXT:    fcvtas x8, s0
; CHECK-GI-NEXT:    sxtw x0, w8
; CHECK-GI-NEXT:    ret
entry:
  %0 = tail call i32 @llvm.lround.i32.f16(half %x)
  %conv = sext i32 %0 to i64
  ret i64 %conv
}
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK: {{.*}}
