1*9880d681SAndroid Build Coastguard Worker; RUN: llc -O0 -verify-machineinstrs -mtriple=arm64-eabi < %s | FileCheck --enable-var-scope %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker; Test fptosi 4*9880d681SAndroid Build Coastguard Workerdefine i32 @fptosi_wh(half %a) nounwind ssp { 5*9880d681SAndroid Build Coastguard Workerentry: 6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fptosi_wh 7*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt s1, h0 8*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtzs [[REG:w[0-9]+]], s1 9*9880d681SAndroid Build Coastguard Worker; CHECK: mov w0, [[REG]] 10*9880d681SAndroid Build Coastguard Worker %conv = fptosi half %a to i32 11*9880d681SAndroid Build Coastguard Worker ret i32 %conv 12*9880d681SAndroid Build Coastguard Worker} 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker; Test fptoui 15*9880d681SAndroid Build Coastguard Workerdefine i32 @fptoui_swh(half %a) nounwind ssp { 16*9880d681SAndroid Build Coastguard Workerentry: 17*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fptoui_swh 18*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt s1, h0 19*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtzu [[REG:w[0-9]+]], s1 20*9880d681SAndroid Build Coastguard Worker; CHECK: mov w0, [[REG]] 21*9880d681SAndroid Build Coastguard Worker %conv = fptoui half %a to i32 22*9880d681SAndroid Build Coastguard Worker ret i32 %conv 23*9880d681SAndroid Build Coastguard Worker} 24*9880d681SAndroid Build Coastguard Worker 25*9880d681SAndroid Build Coastguard Worker; Test sitofp 26*9880d681SAndroid Build Coastguard Workerdefine half @sitofp_hw_i1(i1 %a) nounwind ssp { 27*9880d681SAndroid Build Coastguard Workerentry: 28*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_hw_i1 29*9880d681SAndroid Build Coastguard Worker; CHECK: sbfx w0, w0, #0, #1 30*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf s0, w0 31*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 32*9880d681SAndroid Build Coastguard Worker %conv = sitofp i1 %a to half 33*9880d681SAndroid Build Coastguard Worker ret half %conv 34*9880d681SAndroid Build Coastguard Worker} 35*9880d681SAndroid Build Coastguard Worker 36*9880d681SAndroid Build Coastguard Worker; Test sitofp 37*9880d681SAndroid Build Coastguard Workerdefine half @sitofp_hw_i8(i8 %a) nounwind ssp { 38*9880d681SAndroid Build Coastguard Workerentry: 39*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_hw_i8 40*9880d681SAndroid Build Coastguard Worker; CHECK: sxtb w0, w0 41*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf s0, w0 42*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 43*9880d681SAndroid Build Coastguard Worker %conv = sitofp i8 %a to half 44*9880d681SAndroid Build Coastguard Worker ret half %conv 45*9880d681SAndroid Build Coastguard Worker} 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard Worker; Test sitofp 48*9880d681SAndroid Build Coastguard Workerdefine half @sitofp_hw_i16(i16 %a) nounwind ssp { 49*9880d681SAndroid Build Coastguard Workerentry: 50*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_hw_i16 51*9880d681SAndroid Build Coastguard Worker; CHECK: sxth w0, w0 52*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf s0, w0 53*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 54*9880d681SAndroid Build Coastguard Worker %conv = sitofp i16 %a to half 55*9880d681SAndroid Build Coastguard Worker ret half %conv 56*9880d681SAndroid Build Coastguard Worker} 57*9880d681SAndroid Build Coastguard Worker 58*9880d681SAndroid Build Coastguard Worker; Test sitofp 59*9880d681SAndroid Build Coastguard Workerdefine half @sitofp_hw_i32(i32 %a) nounwind ssp { 60*9880d681SAndroid Build Coastguard Workerentry: 61*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_hw_i32 62*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf s0, w0 63*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 64*9880d681SAndroid Build Coastguard Worker %conv = sitofp i32 %a to half 65*9880d681SAndroid Build Coastguard Worker ret half %conv 66*9880d681SAndroid Build Coastguard Worker} 67*9880d681SAndroid Build Coastguard Worker 68*9880d681SAndroid Build Coastguard Worker; Test sitofp 69*9880d681SAndroid Build Coastguard Workerdefine half @sitofp_hx(i64 %a) nounwind ssp { 70*9880d681SAndroid Build Coastguard Workerentry: 71*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_hx 72*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf s0, x0 73*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 74*9880d681SAndroid Build Coastguard Worker %conv = sitofp i64 %a to half 75*9880d681SAndroid Build Coastguard Worker ret half %conv 76*9880d681SAndroid Build Coastguard Worker} 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Worker; Test uitofp 79*9880d681SAndroid Build Coastguard Workerdefine half @uitofp_hw_i1(i1 %a) nounwind ssp { 80*9880d681SAndroid Build Coastguard Workerentry: 81*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_hw_i1 82*9880d681SAndroid Build Coastguard Worker; CHECK: and w0, w0, #0x1 83*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf s0, w0 84*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 85*9880d681SAndroid Build Coastguard Worker %conv = uitofp i1 %a to half 86*9880d681SAndroid Build Coastguard Worker ret half %conv 87*9880d681SAndroid Build Coastguard Worker} 88*9880d681SAndroid Build Coastguard Worker 89*9880d681SAndroid Build Coastguard Worker; Test uitofp 90*9880d681SAndroid Build Coastguard Workerdefine half @uitofp_hw_i8(i8 %a) nounwind ssp { 91*9880d681SAndroid Build Coastguard Workerentry: 92*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_hw_i8 93*9880d681SAndroid Build Coastguard Worker; CHECK: and w0, w0, #0xff 94*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf s0, w0 95*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 96*9880d681SAndroid Build Coastguard Worker %conv = uitofp i8 %a to half 97*9880d681SAndroid Build Coastguard Worker ret half %conv 98*9880d681SAndroid Build Coastguard Worker} 99*9880d681SAndroid Build Coastguard Worker 100*9880d681SAndroid Build Coastguard Worker; Test uitofp 101*9880d681SAndroid Build Coastguard Workerdefine half @uitofp_hw_i16(i16 %a) nounwind ssp { 102*9880d681SAndroid Build Coastguard Workerentry: 103*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_hw_i16 104*9880d681SAndroid Build Coastguard Worker; CHECK: and w0, w0, #0xffff 105*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf s0, w0 106*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 107*9880d681SAndroid Build Coastguard Worker %conv = uitofp i16 %a to half 108*9880d681SAndroid Build Coastguard Worker ret half %conv 109*9880d681SAndroid Build Coastguard Worker} 110*9880d681SAndroid Build Coastguard Worker 111*9880d681SAndroid Build Coastguard Worker; Test uitofp 112*9880d681SAndroid Build Coastguard Workerdefine half @uitofp_hw_i32(i32 %a) nounwind ssp { 113*9880d681SAndroid Build Coastguard Workerentry: 114*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_hw_i32 115*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf s0, w0 116*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 117*9880d681SAndroid Build Coastguard Worker %conv = uitofp i32 %a to half 118*9880d681SAndroid Build Coastguard Worker ret half %conv 119*9880d681SAndroid Build Coastguard Worker} 120*9880d681SAndroid Build Coastguard Worker 121*9880d681SAndroid Build Coastguard Worker; Test uitofp 122*9880d681SAndroid Build Coastguard Workerdefine half @uitofp_hx(i64 %a) nounwind ssp { 123*9880d681SAndroid Build Coastguard Workerentry: 124*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_hx 125*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf s0, x0 126*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt h0, s0 127*9880d681SAndroid Build Coastguard Worker %conv = uitofp i64 %a to half 128*9880d681SAndroid Build Coastguard Worker ret half %conv 129*9880d681SAndroid Build Coastguard Worker} 130*9880d681SAndroid Build Coastguard Worker 131*9880d681SAndroid Build Coastguard Worker 132