1*9880d681SAndroid Build Coastguard Worker; RUN: llc -O0 -fast-isel-abort=1 -verify-machineinstrs -mtriple=arm64-apple-darwin -mcpu=cyclone < %s | FileCheck %s 2*9880d681SAndroid Build Coastguard Worker 3*9880d681SAndroid Build Coastguard Worker;; Test various conversions. 4*9880d681SAndroid Build Coastguard Workerdefine zeroext i32 @trunc_(i8 zeroext %a, i16 zeroext %b, i32 %c, i64 %d) nounwind ssp { 5*9880d681SAndroid Build Coastguard Workerentry: 6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: trunc_ 7*9880d681SAndroid Build Coastguard Worker; CHECK: sub sp, sp, #16 8*9880d681SAndroid Build Coastguard Worker; CHECK: strb w0, [sp, #15] 9*9880d681SAndroid Build Coastguard Worker; CHECK: strh w1, [sp, #12] 10*9880d681SAndroid Build Coastguard Worker; CHECK: str w2, [sp, #8] 11*9880d681SAndroid Build Coastguard Worker; CHECK: str x3, [sp] 12*9880d681SAndroid Build Coastguard Worker; CHECK: ldr x3, [sp] 13*9880d681SAndroid Build Coastguard Worker; CHECK: mov x0, x3 14*9880d681SAndroid Build Coastguard Worker; CHECK: str w0, [sp, #8] 15*9880d681SAndroid Build Coastguard Worker; CHECK: ldr w0, [sp, #8] 16*9880d681SAndroid Build Coastguard Worker; CHECK: strh w0, [sp, #12] 17*9880d681SAndroid Build Coastguard Worker; CHECK: ldrh w0, [sp, #12] 18*9880d681SAndroid Build Coastguard Worker; CHECK: strb w0, [sp, #15] 19*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb w0, [sp, #15] 20*9880d681SAndroid Build Coastguard Worker; CHECK: add sp, sp, #16 21*9880d681SAndroid Build Coastguard Worker; CHECK: ret 22*9880d681SAndroid Build Coastguard Worker %a.addr = alloca i8, align 1 23*9880d681SAndroid Build Coastguard Worker %b.addr = alloca i16, align 2 24*9880d681SAndroid Build Coastguard Worker %c.addr = alloca i32, align 4 25*9880d681SAndroid Build Coastguard Worker %d.addr = alloca i64, align 8 26*9880d681SAndroid Build Coastguard Worker store i8 %a, i8* %a.addr, align 1 27*9880d681SAndroid Build Coastguard Worker store i16 %b, i16* %b.addr, align 2 28*9880d681SAndroid Build Coastguard Worker store i32 %c, i32* %c.addr, align 4 29*9880d681SAndroid Build Coastguard Worker store i64 %d, i64* %d.addr, align 8 30*9880d681SAndroid Build Coastguard Worker %tmp = load i64, i64* %d.addr, align 8 31*9880d681SAndroid Build Coastguard Worker %conv = trunc i64 %tmp to i32 32*9880d681SAndroid Build Coastguard Worker store i32 %conv, i32* %c.addr, align 4 33*9880d681SAndroid Build Coastguard Worker %tmp1 = load i32, i32* %c.addr, align 4 34*9880d681SAndroid Build Coastguard Worker %conv2 = trunc i32 %tmp1 to i16 35*9880d681SAndroid Build Coastguard Worker store i16 %conv2, i16* %b.addr, align 2 36*9880d681SAndroid Build Coastguard Worker %tmp3 = load i16, i16* %b.addr, align 2 37*9880d681SAndroid Build Coastguard Worker %conv4 = trunc i16 %tmp3 to i8 38*9880d681SAndroid Build Coastguard Worker store i8 %conv4, i8* %a.addr, align 1 39*9880d681SAndroid Build Coastguard Worker %tmp5 = load i8, i8* %a.addr, align 1 40*9880d681SAndroid Build Coastguard Worker %conv6 = zext i8 %tmp5 to i32 41*9880d681SAndroid Build Coastguard Worker ret i32 %conv6 42*9880d681SAndroid Build Coastguard Worker} 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard Workerdefine i64 @zext_(i8 zeroext %a, i16 zeroext %b, i32 %c, i64 %d) nounwind ssp { 45*9880d681SAndroid Build Coastguard Workerentry: 46*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: zext_ 47*9880d681SAndroid Build Coastguard Worker; CHECK: sub sp, sp, #16 48*9880d681SAndroid Build Coastguard Worker; CHECK: strb w0, [sp, #15] 49*9880d681SAndroid Build Coastguard Worker; CHECK: strh w1, [sp, #12] 50*9880d681SAndroid Build Coastguard Worker; CHECK: str w2, [sp, #8] 51*9880d681SAndroid Build Coastguard Worker; CHECK: str x3, [sp] 52*9880d681SAndroid Build Coastguard Worker; CHECK: ldrb w0, [sp, #15] 53*9880d681SAndroid Build Coastguard Worker; CHECK: strh w0, [sp, #12] 54*9880d681SAndroid Build Coastguard Worker; CHECK: ldrh w0, [sp, #12] 55*9880d681SAndroid Build Coastguard Worker; CHECK: str w0, [sp, #8] 56*9880d681SAndroid Build Coastguard Worker; CHECK: ldr w0, [sp, #8] 57*9880d681SAndroid Build Coastguard Worker; CHECK: mov x3, x0 58*9880d681SAndroid Build Coastguard Worker; CHECK: str x3, [sp] 59*9880d681SAndroid Build Coastguard Worker; CHECK: ldr x0, [sp] 60*9880d681SAndroid Build Coastguard Worker; CHECK: ret 61*9880d681SAndroid Build Coastguard Worker %a.addr = alloca i8, align 1 62*9880d681SAndroid Build Coastguard Worker %b.addr = alloca i16, align 2 63*9880d681SAndroid Build Coastguard Worker %c.addr = alloca i32, align 4 64*9880d681SAndroid Build Coastguard Worker %d.addr = alloca i64, align 8 65*9880d681SAndroid Build Coastguard Worker store i8 %a, i8* %a.addr, align 1 66*9880d681SAndroid Build Coastguard Worker store i16 %b, i16* %b.addr, align 2 67*9880d681SAndroid Build Coastguard Worker store i32 %c, i32* %c.addr, align 4 68*9880d681SAndroid Build Coastguard Worker store i64 %d, i64* %d.addr, align 8 69*9880d681SAndroid Build Coastguard Worker %tmp = load i8, i8* %a.addr, align 1 70*9880d681SAndroid Build Coastguard Worker %conv = zext i8 %tmp to i16 71*9880d681SAndroid Build Coastguard Worker store i16 %conv, i16* %b.addr, align 2 72*9880d681SAndroid Build Coastguard Worker %tmp1 = load i16, i16* %b.addr, align 2 73*9880d681SAndroid Build Coastguard Worker %conv2 = zext i16 %tmp1 to i32 74*9880d681SAndroid Build Coastguard Worker store i32 %conv2, i32* %c.addr, align 4 75*9880d681SAndroid Build Coastguard Worker %tmp3 = load i32, i32* %c.addr, align 4 76*9880d681SAndroid Build Coastguard Worker %conv4 = zext i32 %tmp3 to i64 77*9880d681SAndroid Build Coastguard Worker store i64 %conv4, i64* %d.addr, align 8 78*9880d681SAndroid Build Coastguard Worker %tmp5 = load i64, i64* %d.addr, align 8 79*9880d681SAndroid Build Coastguard Worker ret i64 %tmp5 80*9880d681SAndroid Build Coastguard Worker} 81*9880d681SAndroid Build Coastguard Worker 82*9880d681SAndroid Build Coastguard Workerdefine i32 @zext_i1_i32(i1 zeroext %a) nounwind ssp { 83*9880d681SAndroid Build Coastguard Workerentry: 84*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: zext_i1_i32 85*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: and w0, w0, #0x1 86*9880d681SAndroid Build Coastguard Worker; CHECK: ret 87*9880d681SAndroid Build Coastguard Worker %conv = zext i1 %a to i32 88*9880d681SAndroid Build Coastguard Worker ret i32 %conv; 89*9880d681SAndroid Build Coastguard Worker} 90*9880d681SAndroid Build Coastguard Worker 91*9880d681SAndroid Build Coastguard Workerdefine i64 @zext_i1_i64(i1 zeroext %a) nounwind ssp { 92*9880d681SAndroid Build Coastguard Workerentry: 93*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: zext_i1_i64 94*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: and w0, w0, #0x1 95*9880d681SAndroid Build Coastguard Worker; CHECK: ret 96*9880d681SAndroid Build Coastguard Worker %conv = zext i1 %a to i64 97*9880d681SAndroid Build Coastguard Worker ret i64 %conv; 98*9880d681SAndroid Build Coastguard Worker} 99*9880d681SAndroid Build Coastguard Worker 100*9880d681SAndroid Build Coastguard Workerdefine i64 @sext_(i8 signext %a, i16 signext %b, i32 %c, i64 %d) nounwind ssp { 101*9880d681SAndroid Build Coastguard Workerentry: 102*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sext_ 103*9880d681SAndroid Build Coastguard Worker; CHECK: sub sp, sp, #16 104*9880d681SAndroid Build Coastguard Worker; CHECK: strb w0, [sp, #15] 105*9880d681SAndroid Build Coastguard Worker; CHECK: strh w1, [sp, #12] 106*9880d681SAndroid Build Coastguard Worker; CHECK: str w2, [sp, #8] 107*9880d681SAndroid Build Coastguard Worker; CHECK: str x3, [sp] 108*9880d681SAndroid Build Coastguard Worker; CHECK: ldrsb w0, [sp, #15] 109*9880d681SAndroid Build Coastguard Worker; CHECK: strh w0, [sp, #12] 110*9880d681SAndroid Build Coastguard Worker; CHECK: ldrsh w0, [sp, #12] 111*9880d681SAndroid Build Coastguard Worker; CHECK: str w0, [sp, #8] 112*9880d681SAndroid Build Coastguard Worker; CHECK: ldrsw x3, [sp, #8] 113*9880d681SAndroid Build Coastguard Worker; CHECK: str x3, [sp] 114*9880d681SAndroid Build Coastguard Worker; CHECK: ldr x0, [sp] 115*9880d681SAndroid Build Coastguard Worker; CHECK: ret 116*9880d681SAndroid Build Coastguard Worker %a.addr = alloca i8, align 1 117*9880d681SAndroid Build Coastguard Worker %b.addr = alloca i16, align 2 118*9880d681SAndroid Build Coastguard Worker %c.addr = alloca i32, align 4 119*9880d681SAndroid Build Coastguard Worker %d.addr = alloca i64, align 8 120*9880d681SAndroid Build Coastguard Worker store i8 %a, i8* %a.addr, align 1 121*9880d681SAndroid Build Coastguard Worker store i16 %b, i16* %b.addr, align 2 122*9880d681SAndroid Build Coastguard Worker store i32 %c, i32* %c.addr, align 4 123*9880d681SAndroid Build Coastguard Worker store i64 %d, i64* %d.addr, align 8 124*9880d681SAndroid Build Coastguard Worker %tmp = load i8, i8* %a.addr, align 1 125*9880d681SAndroid Build Coastguard Worker %conv = sext i8 %tmp to i16 126*9880d681SAndroid Build Coastguard Worker store i16 %conv, i16* %b.addr, align 2 127*9880d681SAndroid Build Coastguard Worker %tmp1 = load i16, i16* %b.addr, align 2 128*9880d681SAndroid Build Coastguard Worker %conv2 = sext i16 %tmp1 to i32 129*9880d681SAndroid Build Coastguard Worker store i32 %conv2, i32* %c.addr, align 4 130*9880d681SAndroid Build Coastguard Worker %tmp3 = load i32, i32* %c.addr, align 4 131*9880d681SAndroid Build Coastguard Worker %conv4 = sext i32 %tmp3 to i64 132*9880d681SAndroid Build Coastguard Worker store i64 %conv4, i64* %d.addr, align 8 133*9880d681SAndroid Build Coastguard Worker %tmp5 = load i64, i64* %d.addr, align 8 134*9880d681SAndroid Build Coastguard Worker ret i64 %tmp5 135*9880d681SAndroid Build Coastguard Worker} 136*9880d681SAndroid Build Coastguard Worker 137*9880d681SAndroid Build Coastguard Worker; Test sext i8 to i64 138*9880d681SAndroid Build Coastguard Worker 139*9880d681SAndroid Build Coastguard Workerdefine zeroext i64 @sext_i8_i64(i8 zeroext %in) { 140*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sext_i8_i64: 141*9880d681SAndroid Build Coastguard Worker; CHECK: mov x[[TMP:[0-9]+]], x0 142*9880d681SAndroid Build Coastguard Worker; CHECK: sxtb x0, w[[TMP]] 143*9880d681SAndroid Build Coastguard Worker %big = sext i8 %in to i64 144*9880d681SAndroid Build Coastguard Worker ret i64 %big 145*9880d681SAndroid Build Coastguard Worker} 146*9880d681SAndroid Build Coastguard Worker 147*9880d681SAndroid Build Coastguard Workerdefine zeroext i64 @sext_i16_i64(i16 zeroext %in) { 148*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sext_i16_i64: 149*9880d681SAndroid Build Coastguard Worker; CHECK: mov x[[TMP:[0-9]+]], x0 150*9880d681SAndroid Build Coastguard Worker; CHECK: sxth x0, w[[TMP]] 151*9880d681SAndroid Build Coastguard Worker %big = sext i16 %in to i64 152*9880d681SAndroid Build Coastguard Worker ret i64 %big 153*9880d681SAndroid Build Coastguard Worker} 154*9880d681SAndroid Build Coastguard Worker 155*9880d681SAndroid Build Coastguard Worker; Test sext i1 to i32 156*9880d681SAndroid Build Coastguard Workerdefine i32 @sext_i1_i32(i1 signext %a) nounwind ssp { 157*9880d681SAndroid Build Coastguard Workerentry: 158*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sext_i1_i32 159*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: sbfx w0, w0, #0, #1 160*9880d681SAndroid Build Coastguard Worker; CHECK: ret 161*9880d681SAndroid Build Coastguard Worker %conv = sext i1 %a to i32 162*9880d681SAndroid Build Coastguard Worker ret i32 %conv 163*9880d681SAndroid Build Coastguard Worker} 164*9880d681SAndroid Build Coastguard Worker 165*9880d681SAndroid Build Coastguard Worker; Test sext i1 to i16 166*9880d681SAndroid Build Coastguard Workerdefine signext i16 @sext_i1_i16(i1 %a) nounwind ssp { 167*9880d681SAndroid Build Coastguard Workerentry: 168*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sext_i1_i16 169*9880d681SAndroid Build Coastguard Worker; CHECK: sbfx w0, w0, #0, #1 170*9880d681SAndroid Build Coastguard Worker %conv = sext i1 %a to i16 171*9880d681SAndroid Build Coastguard Worker ret i16 %conv 172*9880d681SAndroid Build Coastguard Worker} 173*9880d681SAndroid Build Coastguard Worker 174*9880d681SAndroid Build Coastguard Worker; Test sext i1 to i8 175*9880d681SAndroid Build Coastguard Workerdefine signext i8 @sext_i1_i8(i1 %a) nounwind ssp { 176*9880d681SAndroid Build Coastguard Workerentry: 177*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sext_i1_i8 178*9880d681SAndroid Build Coastguard Worker; CHECK: sbfx w0, w0, #0, #1 179*9880d681SAndroid Build Coastguard Worker %conv = sext i1 %a to i8 180*9880d681SAndroid Build Coastguard Worker ret i8 %conv 181*9880d681SAndroid Build Coastguard Worker} 182*9880d681SAndroid Build Coastguard Worker 183*9880d681SAndroid Build Coastguard Worker; Test fpext 184*9880d681SAndroid Build Coastguard Workerdefine double @fpext_(float %a) nounwind ssp { 185*9880d681SAndroid Build Coastguard Workerentry: 186*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fpext_ 187*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt d0, s0 188*9880d681SAndroid Build Coastguard Worker %conv = fpext float %a to double 189*9880d681SAndroid Build Coastguard Worker ret double %conv 190*9880d681SAndroid Build Coastguard Worker} 191*9880d681SAndroid Build Coastguard Worker 192*9880d681SAndroid Build Coastguard Worker; Test fptrunc 193*9880d681SAndroid Build Coastguard Workerdefine float @fptrunc_(double %a) nounwind ssp { 194*9880d681SAndroid Build Coastguard Workerentry: 195*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fptrunc_ 196*9880d681SAndroid Build Coastguard Worker; CHECK: fcvt s0, d0 197*9880d681SAndroid Build Coastguard Worker %conv = fptrunc double %a to float 198*9880d681SAndroid Build Coastguard Worker ret float %conv 199*9880d681SAndroid Build Coastguard Worker} 200*9880d681SAndroid Build Coastguard Worker 201*9880d681SAndroid Build Coastguard Worker; Test fptosi 202*9880d681SAndroid Build Coastguard Workerdefine i32 @fptosi_ws(float %a) nounwind ssp { 203*9880d681SAndroid Build Coastguard Workerentry: 204*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fptosi_ws 205*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtzs w0, s0 206*9880d681SAndroid Build Coastguard Worker %conv = fptosi float %a to i32 207*9880d681SAndroid Build Coastguard Worker ret i32 %conv 208*9880d681SAndroid Build Coastguard Worker} 209*9880d681SAndroid Build Coastguard Worker 210*9880d681SAndroid Build Coastguard Worker; Test fptosi 211*9880d681SAndroid Build Coastguard Workerdefine i32 @fptosi_wd(double %a) nounwind ssp { 212*9880d681SAndroid Build Coastguard Workerentry: 213*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fptosi_wd 214*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtzs w0, d0 215*9880d681SAndroid Build Coastguard Worker %conv = fptosi double %a to i32 216*9880d681SAndroid Build Coastguard Worker ret i32 %conv 217*9880d681SAndroid Build Coastguard Worker} 218*9880d681SAndroid Build Coastguard Worker 219*9880d681SAndroid Build Coastguard Worker; Test fptoui 220*9880d681SAndroid Build Coastguard Workerdefine i32 @fptoui_ws(float %a) nounwind ssp { 221*9880d681SAndroid Build Coastguard Workerentry: 222*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fptoui_ws 223*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtzu w0, s0 224*9880d681SAndroid Build Coastguard Worker %conv = fptoui float %a to i32 225*9880d681SAndroid Build Coastguard Worker ret i32 %conv 226*9880d681SAndroid Build Coastguard Worker} 227*9880d681SAndroid Build Coastguard Worker 228*9880d681SAndroid Build Coastguard Worker; Test fptoui 229*9880d681SAndroid Build Coastguard Workerdefine i32 @fptoui_wd(double %a) nounwind ssp { 230*9880d681SAndroid Build Coastguard Workerentry: 231*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: fptoui_wd 232*9880d681SAndroid Build Coastguard Worker; CHECK: fcvtzu w0, d0 233*9880d681SAndroid Build Coastguard Worker %conv = fptoui double %a to i32 234*9880d681SAndroid Build Coastguard Worker ret i32 %conv 235*9880d681SAndroid Build Coastguard Worker} 236*9880d681SAndroid Build Coastguard Worker 237*9880d681SAndroid Build Coastguard Worker; Test sitofp 238*9880d681SAndroid Build Coastguard Workerdefine float @sitofp_sw_i1(i1 %a) nounwind ssp { 239*9880d681SAndroid Build Coastguard Workerentry: 240*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_sw_i1 241*9880d681SAndroid Build Coastguard Worker; CHECK: sbfx w0, w0, #0, #1 242*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf s0, w0 243*9880d681SAndroid Build Coastguard Worker %conv = sitofp i1 %a to float 244*9880d681SAndroid Build Coastguard Worker ret float %conv 245*9880d681SAndroid Build Coastguard Worker} 246*9880d681SAndroid Build Coastguard Worker 247*9880d681SAndroid Build Coastguard Worker; Test sitofp 248*9880d681SAndroid Build Coastguard Workerdefine float @sitofp_sw_i8(i8 %a) nounwind ssp { 249*9880d681SAndroid Build Coastguard Workerentry: 250*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_sw_i8 251*9880d681SAndroid Build Coastguard Worker; CHECK: sxtb w0, w0 252*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf s0, w0 253*9880d681SAndroid Build Coastguard Worker %conv = sitofp i8 %a to float 254*9880d681SAndroid Build Coastguard Worker ret float %conv 255*9880d681SAndroid Build Coastguard Worker} 256*9880d681SAndroid Build Coastguard Worker 257*9880d681SAndroid Build Coastguard Worker; Test sitofp 258*9880d681SAndroid Build Coastguard Workerdefine float @sitofp_sw_i16(i16 %a) nounwind ssp { 259*9880d681SAndroid Build Coastguard Workerentry: 260*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_sw_i16 261*9880d681SAndroid Build Coastguard Worker %conv = sitofp i16 %a to float 262*9880d681SAndroid Build Coastguard Worker ret float %conv 263*9880d681SAndroid Build Coastguard Worker} 264*9880d681SAndroid Build Coastguard Worker 265*9880d681SAndroid Build Coastguard Worker; Test sitofp 266*9880d681SAndroid Build Coastguard Workerdefine float @sitofp_sw(i32 %a) nounwind ssp { 267*9880d681SAndroid Build Coastguard Workerentry: 268*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_sw 269*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf s0, w0 270*9880d681SAndroid Build Coastguard Worker %conv = sitofp i32 %a to float 271*9880d681SAndroid Build Coastguard Worker ret float %conv 272*9880d681SAndroid Build Coastguard Worker} 273*9880d681SAndroid Build Coastguard Worker 274*9880d681SAndroid Build Coastguard Worker; Test sitofp 275*9880d681SAndroid Build Coastguard Workerdefine float @sitofp_sx(i64 %a) nounwind ssp { 276*9880d681SAndroid Build Coastguard Workerentry: 277*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_sx 278*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf s0, x0 279*9880d681SAndroid Build Coastguard Worker %conv = sitofp i64 %a to float 280*9880d681SAndroid Build Coastguard Worker ret float %conv 281*9880d681SAndroid Build Coastguard Worker} 282*9880d681SAndroid Build Coastguard Worker 283*9880d681SAndroid Build Coastguard Worker; Test sitofp 284*9880d681SAndroid Build Coastguard Workerdefine double @sitofp_dw(i32 %a) nounwind ssp { 285*9880d681SAndroid Build Coastguard Workerentry: 286*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_dw 287*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf d0, w0 288*9880d681SAndroid Build Coastguard Worker %conv = sitofp i32 %a to double 289*9880d681SAndroid Build Coastguard Worker ret double %conv 290*9880d681SAndroid Build Coastguard Worker} 291*9880d681SAndroid Build Coastguard Worker 292*9880d681SAndroid Build Coastguard Worker; Test sitofp 293*9880d681SAndroid Build Coastguard Workerdefine double @sitofp_dx(i64 %a) nounwind ssp { 294*9880d681SAndroid Build Coastguard Workerentry: 295*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: sitofp_dx 296*9880d681SAndroid Build Coastguard Worker; CHECK: scvtf d0, x0 297*9880d681SAndroid Build Coastguard Worker %conv = sitofp i64 %a to double 298*9880d681SAndroid Build Coastguard Worker ret double %conv 299*9880d681SAndroid Build Coastguard Worker} 300*9880d681SAndroid Build Coastguard Worker 301*9880d681SAndroid Build Coastguard Worker; Test uitofp 302*9880d681SAndroid Build Coastguard Workerdefine float @uitofp_sw_i1(i1 %a) nounwind ssp { 303*9880d681SAndroid Build Coastguard Workerentry: 304*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_sw_i1 305*9880d681SAndroid Build Coastguard Worker; CHECK: and w0, w0, #0x1 306*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf s0, w0 307*9880d681SAndroid Build Coastguard Worker %conv = uitofp i1 %a to float 308*9880d681SAndroid Build Coastguard Worker ret float %conv 309*9880d681SAndroid Build Coastguard Worker} 310*9880d681SAndroid Build Coastguard Worker 311*9880d681SAndroid Build Coastguard Worker; Test uitofp 312*9880d681SAndroid Build Coastguard Workerdefine float @uitofp_sw_i8(i8 %a) nounwind ssp { 313*9880d681SAndroid Build Coastguard Workerentry: 314*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_sw_i8 315*9880d681SAndroid Build Coastguard Worker %conv = uitofp i8 %a to float 316*9880d681SAndroid Build Coastguard Worker ret float %conv 317*9880d681SAndroid Build Coastguard Worker} 318*9880d681SAndroid Build Coastguard Worker 319*9880d681SAndroid Build Coastguard Worker; Test uitofp 320*9880d681SAndroid Build Coastguard Workerdefine float @uitofp_sw_i16(i16 %a) nounwind ssp { 321*9880d681SAndroid Build Coastguard Workerentry: 322*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_sw_i16 323*9880d681SAndroid Build Coastguard Worker %conv = uitofp i16 %a to float 324*9880d681SAndroid Build Coastguard Worker ret float %conv 325*9880d681SAndroid Build Coastguard Worker} 326*9880d681SAndroid Build Coastguard Worker 327*9880d681SAndroid Build Coastguard Worker; Test uitofp 328*9880d681SAndroid Build Coastguard Workerdefine float @uitofp_sw(i32 %a) nounwind ssp { 329*9880d681SAndroid Build Coastguard Workerentry: 330*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_sw 331*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf s0, w0 332*9880d681SAndroid Build Coastguard Worker %conv = uitofp i32 %a to float 333*9880d681SAndroid Build Coastguard Worker ret float %conv 334*9880d681SAndroid Build Coastguard Worker} 335*9880d681SAndroid Build Coastguard Worker 336*9880d681SAndroid Build Coastguard Worker; Test uitofp 337*9880d681SAndroid Build Coastguard Workerdefine float @uitofp_sx(i64 %a) nounwind ssp { 338*9880d681SAndroid Build Coastguard Workerentry: 339*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_sx 340*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf s0, x0 341*9880d681SAndroid Build Coastguard Worker %conv = uitofp i64 %a to float 342*9880d681SAndroid Build Coastguard Worker ret float %conv 343*9880d681SAndroid Build Coastguard Worker} 344*9880d681SAndroid Build Coastguard Worker 345*9880d681SAndroid Build Coastguard Worker; Test uitofp 346*9880d681SAndroid Build Coastguard Workerdefine double @uitofp_dw(i32 %a) nounwind ssp { 347*9880d681SAndroid Build Coastguard Workerentry: 348*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_dw 349*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf d0, w0 350*9880d681SAndroid Build Coastguard Worker %conv = uitofp i32 %a to double 351*9880d681SAndroid Build Coastguard Worker ret double %conv 352*9880d681SAndroid Build Coastguard Worker} 353*9880d681SAndroid Build Coastguard Worker 354*9880d681SAndroid Build Coastguard Worker; Test uitofp 355*9880d681SAndroid Build Coastguard Workerdefine double @uitofp_dx(i64 %a) nounwind ssp { 356*9880d681SAndroid Build Coastguard Workerentry: 357*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: uitofp_dx 358*9880d681SAndroid Build Coastguard Worker; CHECK: ucvtf d0, x0 359*9880d681SAndroid Build Coastguard Worker %conv = uitofp i64 %a to double 360*9880d681SAndroid Build Coastguard Worker ret double %conv 361*9880d681SAndroid Build Coastguard Worker} 362*9880d681SAndroid Build Coastguard Worker 363*9880d681SAndroid Build Coastguard Workerdefine i32 @i64_trunc_i32(i64 %a) nounwind ssp { 364*9880d681SAndroid Build Coastguard Workerentry: 365*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: i64_trunc_i32 366*9880d681SAndroid Build Coastguard Worker; CHECK: mov x1, x0 367*9880d681SAndroid Build Coastguard Worker %conv = trunc i64 %a to i32 368*9880d681SAndroid Build Coastguard Worker ret i32 %conv 369*9880d681SAndroid Build Coastguard Worker} 370*9880d681SAndroid Build Coastguard Worker 371*9880d681SAndroid Build Coastguard Workerdefine zeroext i16 @i64_trunc_i16(i64 %a) nounwind ssp { 372*9880d681SAndroid Build Coastguard Workerentry: 373*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: i64_trunc_i16 374*9880d681SAndroid Build Coastguard Worker; CHECK: mov x[[REG:[0-9]+]], x0 375*9880d681SAndroid Build Coastguard Worker; CHECK: and [[REG2:w[0-9]+]], w[[REG]], #0xffff 376*9880d681SAndroid Build Coastguard Worker; CHECK: uxth w0, [[REG2]] 377*9880d681SAndroid Build Coastguard Worker %conv = trunc i64 %a to i16 378*9880d681SAndroid Build Coastguard Worker ret i16 %conv 379*9880d681SAndroid Build Coastguard Worker} 380*9880d681SAndroid Build Coastguard Worker 381*9880d681SAndroid Build Coastguard Workerdefine zeroext i8 @i64_trunc_i8(i64 %a) nounwind ssp { 382*9880d681SAndroid Build Coastguard Workerentry: 383*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: i64_trunc_i8 384*9880d681SAndroid Build Coastguard Worker; CHECK: mov x[[REG:[0-9]+]], x0 385*9880d681SAndroid Build Coastguard Worker; CHECK: and [[REG2:w[0-9]+]], w[[REG]], #0xff 386*9880d681SAndroid Build Coastguard Worker; CHECK: uxtb w0, [[REG2]] 387*9880d681SAndroid Build Coastguard Worker %conv = trunc i64 %a to i8 388*9880d681SAndroid Build Coastguard Worker ret i8 %conv 389*9880d681SAndroid Build Coastguard Worker} 390*9880d681SAndroid Build Coastguard Worker 391*9880d681SAndroid Build Coastguard Workerdefine zeroext i1 @i64_trunc_i1(i64 %a) nounwind ssp { 392*9880d681SAndroid Build Coastguard Workerentry: 393*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: i64_trunc_i1 394*9880d681SAndroid Build Coastguard Worker; CHECK: mov x[[REG:[0-9]+]], x0 395*9880d681SAndroid Build Coastguard Worker; CHECK: and [[REG2:w[0-9]+]], w[[REG]], #0x1 396*9880d681SAndroid Build Coastguard Worker; CHECK: and w0, [[REG2]], #0x1 397*9880d681SAndroid Build Coastguard Worker %conv = trunc i64 %a to i1 398*9880d681SAndroid Build Coastguard Worker ret i1 %conv 399*9880d681SAndroid Build Coastguard Worker} 400*9880d681SAndroid Build Coastguard Worker 401*9880d681SAndroid Build Coastguard Worker; rdar://15101939 402*9880d681SAndroid Build Coastguard Workerdefine void @stack_trunc() nounwind { 403*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: stack_trunc 404*9880d681SAndroid Build Coastguard Worker; CHECK: sub sp, sp, #16 405*9880d681SAndroid Build Coastguard Worker; CHECK: ldr [[REG:x[0-9]+]], [sp] 406*9880d681SAndroid Build Coastguard Worker; CHECK: mov x[[REG2:[0-9]+]], [[REG]] 407*9880d681SAndroid Build Coastguard Worker; CHECK: and [[REG3:w[0-9]+]], w[[REG2]], #0xff 408*9880d681SAndroid Build Coastguard Worker; CHECK: strb [[REG3]], [sp, #15] 409*9880d681SAndroid Build Coastguard Worker; CHECK: add sp, sp, #16 410*9880d681SAndroid Build Coastguard Worker %a = alloca i8, align 1 411*9880d681SAndroid Build Coastguard Worker %b = alloca i64, align 8 412*9880d681SAndroid Build Coastguard Worker %c = load i64, i64* %b, align 8 413*9880d681SAndroid Build Coastguard Worker %d = trunc i64 %c to i8 414*9880d681SAndroid Build Coastguard Worker store i8 %d, i8* %a, align 1 415*9880d681SAndroid Build Coastguard Worker ret void 416*9880d681SAndroid Build Coastguard Worker} 417*9880d681SAndroid Build Coastguard Worker 418*9880d681SAndroid Build Coastguard Workerdefine zeroext i64 @zext_i8_i64(i8 zeroext %in) { 419*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: zext_i8_i64: 420*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: ubfx x0, {{x[0-9]+}}, #0, #8 421*9880d681SAndroid Build Coastguard Worker; CHECK: ret 422*9880d681SAndroid Build Coastguard Worker %big = zext i8 %in to i64 423*9880d681SAndroid Build Coastguard Worker ret i64 %big 424*9880d681SAndroid Build Coastguard Worker} 425*9880d681SAndroid Build Coastguard Workerdefine zeroext i64 @zext_i16_i64(i16 zeroext %in) { 426*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: zext_i16_i64: 427*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: ubfx x0, {{x[0-9]+}}, #0, #16 428*9880d681SAndroid Build Coastguard Worker; CHECK: ret 429*9880d681SAndroid Build Coastguard Worker %big = zext i16 %in to i64 430*9880d681SAndroid Build Coastguard Worker ret i64 %big 431*9880d681SAndroid Build Coastguard Worker} 432*9880d681SAndroid Build Coastguard Worker 433*9880d681SAndroid Build Coastguard Workerdefine float @bitcast_i32_to_float(i32 %a) { 434*9880d681SAndroid Build Coastguard Worker %1 = bitcast i32 %a to float 435*9880d681SAndroid Build Coastguard Worker ret float %1 436*9880d681SAndroid Build Coastguard Worker} 437*9880d681SAndroid Build Coastguard Worker 438*9880d681SAndroid Build Coastguard Workerdefine double @bitcast_i64_to_double(i64 %a) { 439*9880d681SAndroid Build Coastguard Worker %1 = bitcast i64 %a to double 440*9880d681SAndroid Build Coastguard Worker ret double %1 441*9880d681SAndroid Build Coastguard Worker} 442*9880d681SAndroid Build Coastguard Worker 443*9880d681SAndroid Build Coastguard Workerdefine i32 @bitcast_float_to_i32(float %a) { 444*9880d681SAndroid Build Coastguard Worker %1 = bitcast float %a to i32 445*9880d681SAndroid Build Coastguard Worker ret i32 %1 446*9880d681SAndroid Build Coastguard Worker} 447*9880d681SAndroid Build Coastguard Worker 448*9880d681SAndroid Build Coastguard Workerdefine i64 @bitcast_double_to_i64(double %a) { 449*9880d681SAndroid Build Coastguard Worker %1 = bitcast double %a to i64 450*9880d681SAndroid Build Coastguard Worker ret i64 %1 451*9880d681SAndroid Build Coastguard Worker} 452*9880d681SAndroid Build Coastguard Worker 453