654 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2 3; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-keep-registers | FileCheck %s --check-prefixes=ALL,DEFISEL4; RUN: llc < %s -disable-wasm-fallthrough-return-opt -wasm-keep-registers -fast-isel | FileCheck %s --check-prefixes=ALL,FASTISEL5 6; Tests for various operations on half precison float. Much of the test is7; copied from test/CodeGen/X86/half.ll.8 9target triple = "wasm32-unknown-unknown"10 11define void @store(half %x, ptr %p) nounwind {12; ALL-LABEL: store:13; ALL: .functype store (f32, i32) -> ()14; ALL-NEXT: # %bb.0:15; ALL-NEXT: local.get $push2=, 116; ALL-NEXT: local.get $push1=, 017; ALL-NEXT: call $push0=, __truncsfhf2, $pop118; ALL-NEXT: i32.store16 0($pop2), $pop019; ALL-NEXT: return20 store half %x, ptr %p21 ret void22}23 24define half @return(ptr %p) nounwind {25; ALL-LABEL: return:26; ALL: .functype return (i32) -> (f32)27; ALL-NEXT: # %bb.0:28; ALL-NEXT: local.get $push2=, 029; ALL-NEXT: i32.load16_u $push0=, 0($pop2)30; ALL-NEXT: call $push1=, __extendhfsf2, $pop031; ALL-NEXT: return $pop132 %r = load half, ptr %p33 ret half %r34}35 36define dso_local double @loadd(ptr nocapture readonly %a) local_unnamed_addr nounwind {37; DEFISEL-LABEL: loadd:38; DEFISEL: .functype loadd (i32) -> (f64)39; DEFISEL-NEXT: # %bb.0:40; DEFISEL-NEXT: local.get $push3=, 041; DEFISEL-NEXT: i32.load16_u $push0=, 2($pop3)42; DEFISEL-NEXT: call $push1=, __extendhfsf2, $pop043; DEFISEL-NEXT: f64.promote_f32 $push2=, $pop144; DEFISEL-NEXT: return $pop245;46; FASTISEL-LABEL: loadd:47; FASTISEL: .functype loadd (i32) -> (f64)48; FASTISEL-NEXT: # %bb.0:49; FASTISEL-NEXT: local.get $push3=, 050; FASTISEL-NEXT: i32.load16_u $push2=, 2($pop3)51; FASTISEL-NEXT: call $push1=, __extendhfsf2, $pop252; FASTISEL-NEXT: f64.promote_f32 $push0=, $pop153; FASTISEL-NEXT: return $pop054 %arrayidx = getelementptr inbounds i16, ptr %a, i64 155 %x = load i16, ptr %arrayidx, align 256 %ret = tail call double @llvm.convert.from.fp16.f64(i16 %x)57 ret double %ret58}59 60define dso_local float @loadf(ptr nocapture readonly %a) local_unnamed_addr nounwind {61; DEFISEL-LABEL: loadf:62; DEFISEL: .functype loadf (i32) -> (f32)63; DEFISEL-NEXT: # %bb.0:64; DEFISEL-NEXT: local.get $push2=, 065; DEFISEL-NEXT: i32.load16_u $push0=, 2($pop2)66; DEFISEL-NEXT: call $push1=, __extendhfsf2, $pop067; DEFISEL-NEXT: return $pop168;69; FASTISEL-LABEL: loadf:70; FASTISEL: .functype loadf (i32) -> (f32)71; FASTISEL-NEXT: # %bb.0:72; FASTISEL-NEXT: local.get $push2=, 073; FASTISEL-NEXT: i32.load16_u $push1=, 2($pop2)74; FASTISEL-NEXT: call $push0=, __extendhfsf2, $pop175; FASTISEL-NEXT: return $pop076 %arrayidx = getelementptr inbounds i16, ptr %a, i64 177 %x = load i16, ptr %arrayidx, align 278 %ret = tail call float @llvm.convert.from.fp16.f32(i16 %x)79 ret float %ret80}81 82define dso_local void @stored(ptr nocapture %a, double %b) local_unnamed_addr nounwind {83; DEFISEL-LABEL: stored:84; DEFISEL: .functype stored (i32, f64) -> ()85; DEFISEL-NEXT: # %bb.0:86; DEFISEL-NEXT: local.get $push2=, 087; DEFISEL-NEXT: local.get $push1=, 188; DEFISEL-NEXT: call $push0=, __truncdfhf2, $pop189; DEFISEL-NEXT: i32.store16 0($pop2), $pop090; DEFISEL-NEXT: return91;92; FASTISEL-LABEL: stored:93; FASTISEL: .functype stored (i32, f64) -> ()94; FASTISEL-NEXT: # %bb.0:95; FASTISEL-NEXT: local.get $push4=, 096; FASTISEL-NEXT: local.get $push3=, 197; FASTISEL-NEXT: call $push2=, __truncdfhf2, $pop398; FASTISEL-NEXT: i32.const $push1=, 6553599; FASTISEL-NEXT: i32.and $push0=, $pop2, $pop1100; FASTISEL-NEXT: i32.store16 0($pop4), $pop0101; FASTISEL-NEXT: return102 %x = tail call i16 @llvm.convert.to.fp16.f64(double %b)103 store i16 %x, ptr %a, align 2104 ret void105}106 107define dso_local void @storef(ptr nocapture %a, float %b) local_unnamed_addr nounwind {108; DEFISEL-LABEL: storef:109; DEFISEL: .functype storef (i32, f32) -> ()110; DEFISEL-NEXT: # %bb.0:111; DEFISEL-NEXT: local.get $push2=, 0112; DEFISEL-NEXT: local.get $push1=, 1113; DEFISEL-NEXT: call $push0=, __truncsfhf2, $pop1114; DEFISEL-NEXT: i32.store16 0($pop2), $pop0115; DEFISEL-NEXT: return116;117; FASTISEL-LABEL: storef:118; FASTISEL: .functype storef (i32, f32) -> ()119; FASTISEL-NEXT: # %bb.0:120; FASTISEL-NEXT: local.get $push4=, 0121; FASTISEL-NEXT: local.get $push3=, 1122; FASTISEL-NEXT: call $push2=, __truncsfhf2, $pop3123; FASTISEL-NEXT: i32.const $push1=, 65535124; FASTISEL-NEXT: i32.and $push0=, $pop2, $pop1125; FASTISEL-NEXT: i32.store16 0($pop4), $pop0126; FASTISEL-NEXT: return127 %x = tail call i16 @llvm.convert.to.fp16.f32(float %b)128 store i16 %x, ptr %a, align 2129 ret void130}131 132define void @test_load_store(ptr %in, ptr %out) nounwind {133; ALL-LABEL: test_load_store:134; ALL: .functype test_load_store (i32, i32) -> ()135; ALL-NEXT: # %bb.0:136; ALL-NEXT: local.get $push2=, 1137; ALL-NEXT: local.get $push1=, 0138; ALL-NEXT: i32.load16_u $push0=, 0($pop1)139; ALL-NEXT: i32.store16 0($pop2), $pop0140; ALL-NEXT: return141 %val = load half, ptr %in142 store half %val, ptr %out143 ret void144}145 146define i16 @test_bitcast_from_half(ptr %addr) nounwind {147; ALL-LABEL: test_bitcast_from_half:148; ALL: .functype test_bitcast_from_half (i32) -> (i32)149; ALL-NEXT: # %bb.0:150; ALL-NEXT: local.get $push1=, 0151; ALL-NEXT: i32.load16_u $push0=, 0($pop1)152; ALL-NEXT: return $pop0153 %val = load half, ptr %addr154 %val_int = bitcast half %val to i16155 ret i16 %val_int156}157 158define void @test_bitcast_to_half(ptr %addr, i16 %in) nounwind {159; ALL-LABEL: test_bitcast_to_half:160; ALL: .functype test_bitcast_to_half (i32, i32) -> ()161; ALL-NEXT: # %bb.0:162; ALL-NEXT: local.get $push1=, 0163; ALL-NEXT: local.get $push0=, 1164; ALL-NEXT: i32.store16 0($pop1), $pop0165; ALL-NEXT: return166 %val_fp = bitcast i16 %in to half167 store half %val_fp, ptr %addr168 ret void169}170 171define half @from_bits(i16 %x) nounwind {172; ALL-LABEL: from_bits:173; ALL: .functype from_bits (i32) -> (f32)174; ALL-NEXT: # %bb.0:175; ALL-NEXT: local.get $push1=, 0176; ALL-NEXT: call $push0=, __extendhfsf2, $pop1177; ALL-NEXT: return $pop0178 %res = bitcast i16 %x to half179 ret half %res180}181 182define i16 @to_bits(half %x) nounwind {183; DEFISEL-LABEL: to_bits:184; DEFISEL: .functype to_bits (f32) -> (i32)185; DEFISEL-NEXT: # %bb.0:186; DEFISEL-NEXT: local.get $push3=, 0187; DEFISEL-NEXT: call $push1=, __truncsfhf2, $pop3188; DEFISEL-NEXT: i32.const $push0=, 65535189; DEFISEL-NEXT: i32.and $push2=, $pop1, $pop0190; DEFISEL-NEXT: return $pop2191;192; FASTISEL-LABEL: to_bits:193; FASTISEL: .functype to_bits (f32) -> (i32)194; FASTISEL-NEXT: # %bb.0:195; FASTISEL-NEXT: local.get $push3=, 0196; FASTISEL-NEXT: call $push2=, __truncsfhf2, $pop3197; FASTISEL-NEXT: i32.const $push1=, 65535198; FASTISEL-NEXT: i32.and $push0=, $pop2, $pop1199; FASTISEL-NEXT: return $pop0200 %res = bitcast half %x to i16201 ret i16 %res202}203 204define float @test_extend32(ptr %addr) nounwind {205; DEFISEL-LABEL: test_extend32:206; DEFISEL: .functype test_extend32 (i32) -> (f32)207; DEFISEL-NEXT: # %bb.0:208; DEFISEL-NEXT: local.get $push2=, 0209; DEFISEL-NEXT: i32.load16_u $push0=, 0($pop2)210; DEFISEL-NEXT: call $push1=, __extendhfsf2, $pop0211; DEFISEL-NEXT: return $pop1212;213; FASTISEL-LABEL: test_extend32:214; FASTISEL: .functype test_extend32 (i32) -> (f32)215; FASTISEL-NEXT: # %bb.0:216; FASTISEL-NEXT: local.get $push2=, 0217; FASTISEL-NEXT: i32.load16_u $push1=, 0($pop2)218; FASTISEL-NEXT: call $push0=, __extendhfsf2, $pop1219; FASTISEL-NEXT: return $pop0220 %val16 = load half, ptr %addr221 %val32 = fpext half %val16 to float222 ret float %val32223}224 225define double @test_extend64(ptr %addr) nounwind {226; DEFISEL-LABEL: test_extend64:227; DEFISEL: .functype test_extend64 (i32) -> (f64)228; DEFISEL-NEXT: # %bb.0:229; DEFISEL-NEXT: local.get $push3=, 0230; DEFISEL-NEXT: i32.load16_u $push0=, 0($pop3)231; DEFISEL-NEXT: call $push1=, __extendhfsf2, $pop0232; DEFISEL-NEXT: f64.promote_f32 $push2=, $pop1233; DEFISEL-NEXT: return $pop2234;235; FASTISEL-LABEL: test_extend64:236; FASTISEL: .functype test_extend64 (i32) -> (f64)237; FASTISEL-NEXT: # %bb.0:238; FASTISEL-NEXT: local.get $push3=, 0239; FASTISEL-NEXT: i32.load16_u $push1=, 0($pop3)240; FASTISEL-NEXT: call $push2=, __extendhfsf2, $pop1241; FASTISEL-NEXT: f64.promote_f32 $push0=, $pop2242; FASTISEL-NEXT: return $pop0243 %val16 = load half, ptr %addr244 %val32 = fpext half %val16 to double245 ret double %val32246}247 248define fp128 @test_extend128(ptr %addr) nounwind {249; ALL-LABEL: test_extend128:250; ALL: .functype test_extend128 (i32, i32) -> ()251; ALL-NEXT: .local i32252; ALL-NEXT: # %bb.0:253; ALL-NEXT: global.get $push4=, __stack_pointer254; ALL-NEXT: i32.const $push5=, 16255; ALL-NEXT: i32.sub $push9=, $pop4, $pop5256; ALL-NEXT: local.tee $push8=, 2, $pop9257; ALL-NEXT: global.set __stack_pointer, $pop8258; ALL-NEXT: local.get $push11=, 2259; ALL-NEXT: local.get $push10=, 1260; ALL-NEXT: i32.load16_u $push0=, 0($pop10)261; ALL-NEXT: call $push1=, __extendhfsf2, $pop0262; ALL-NEXT: call __extendsftf2, $pop11, $pop1263; ALL-NEXT: local.get $push13=, 0264; ALL-NEXT: local.get $push12=, 2265; ALL-NEXT: i64.load $push2=, 8($pop12)266; ALL-NEXT: i64.store 8($pop13), $pop2267; ALL-NEXT: local.get $push15=, 0268; ALL-NEXT: local.get $push14=, 2269; ALL-NEXT: i64.load $push3=, 0($pop14)270; ALL-NEXT: i64.store 0($pop15), $pop3271; ALL-NEXT: local.get $push16=, 2272; ALL-NEXT: i32.const $push6=, 16273; ALL-NEXT: i32.add $push7=, $pop16, $pop6274; ALL-NEXT: global.set __stack_pointer, $pop7275; ALL-NEXT: return276 %val16 = load half, ptr %addr277 %val32 = fpext half %val16 to fp128278 ret fp128 %val32279}280 281define void @test_trunc32(float %in, ptr %addr) nounwind {282; ALL-LABEL: test_trunc32:283; ALL: .functype test_trunc32 (f32, i32) -> ()284; ALL-NEXT: # %bb.0:285; ALL-NEXT: local.get $push2=, 1286; ALL-NEXT: local.get $push1=, 0287; ALL-NEXT: call $push0=, __truncsfhf2, $pop1288; ALL-NEXT: i32.store16 0($pop2), $pop0289; ALL-NEXT: return290 %val16 = fptrunc float %in to half291 store half %val16, ptr %addr292 ret void293}294 295define void @test_trunc64(double %in, ptr %addr) nounwind {296; ALL-LABEL: test_trunc64:297; ALL: .functype test_trunc64 (f64, i32) -> ()298; ALL-NEXT: # %bb.0:299; ALL-NEXT: local.get $push2=, 1300; ALL-NEXT: local.get $push1=, 0301; ALL-NEXT: call $push0=, __truncdfhf2, $pop1302; ALL-NEXT: i32.store16 0($pop2), $pop0303; ALL-NEXT: return304 %val16 = fptrunc double %in to half305 store half %val16, ptr %addr306 ret void307}308 309define void @test_trunc128(fp128 %in, ptr %addr) nounwind {310; ALL-LABEL: test_trunc128:311; ALL: .functype test_trunc128 (i64, i64, i32) -> ()312; ALL-NEXT: # %bb.0:313; ALL-NEXT: local.get $push3=, 2314; ALL-NEXT: local.get $push2=, 0315; ALL-NEXT: local.get $push1=, 1316; ALL-NEXT: call $push0=, __trunctfhf2, $pop2, $pop1317; ALL-NEXT: i32.store16 0($pop3), $pop0318; ALL-NEXT: return319 %val16 = fptrunc fp128 %in to half320 store half %val16, ptr %addr321 ret void322}323 324define i64 @test_fptosi_i64(ptr %p) nounwind {325; DEFISEL-LABEL: test_fptosi_i64:326; DEFISEL: .functype test_fptosi_i64 (i32) -> (i64)327; DEFISEL-NEXT: # %bb.0:328; DEFISEL-NEXT: local.get $push3=, 0329; DEFISEL-NEXT: i32.load16_u $push0=, 0($pop3)330; DEFISEL-NEXT: call $push1=, __extendhfsf2, $pop0331; DEFISEL-NEXT: i64.trunc_sat_f32_s $push2=, $pop1332; DEFISEL-NEXT: return $pop2333;334; FASTISEL-LABEL: test_fptosi_i64:335; FASTISEL: .functype test_fptosi_i64 (i32) -> (i64)336; FASTISEL-NEXT: # %bb.0:337; FASTISEL-NEXT: local.get $push3=, 0338; FASTISEL-NEXT: i32.load16_u $push1=, 0($pop3)339; FASTISEL-NEXT: call $push2=, __extendhfsf2, $pop1340; FASTISEL-NEXT: i64.trunc_sat_f32_s $push0=, $pop2341; FASTISEL-NEXT: return $pop0342 %a = load half, ptr %p, align 2343 %r = fptosi half %a to i64344 ret i64 %r345}346 347define void @test_sitofp_i64(i64 %a, ptr %p) nounwind {348; ALL-LABEL: test_sitofp_i64:349; ALL: .functype test_sitofp_i64 (i64, i32) -> ()350; ALL-NEXT: # %bb.0:351; ALL-NEXT: local.get $push3=, 1352; ALL-NEXT: local.get $push2=, 0353; ALL-NEXT: f32.convert_i64_s $push0=, $pop2354; ALL-NEXT: call $push1=, __truncsfhf2, $pop0355; ALL-NEXT: i32.store16 0($pop3), $pop1356; ALL-NEXT: return357 %r = sitofp i64 %a to half358 store half %r, ptr %p359 ret void360}361 362define i64 @test_fptoui_i64(ptr %p) nounwind {363; DEFISEL-LABEL: test_fptoui_i64:364; DEFISEL: .functype test_fptoui_i64 (i32) -> (i64)365; DEFISEL-NEXT: # %bb.0:366; DEFISEL-NEXT: local.get $push3=, 0367; DEFISEL-NEXT: i32.load16_u $push0=, 0($pop3)368; DEFISEL-NEXT: call $push1=, __extendhfsf2, $pop0369; DEFISEL-NEXT: i64.trunc_sat_f32_u $push2=, $pop1370; DEFISEL-NEXT: return $pop2371;372; FASTISEL-LABEL: test_fptoui_i64:373; FASTISEL: .functype test_fptoui_i64 (i32) -> (i64)374; FASTISEL-NEXT: # %bb.0:375; FASTISEL-NEXT: local.get $push3=, 0376; FASTISEL-NEXT: i32.load16_u $push1=, 0($pop3)377; FASTISEL-NEXT: call $push2=, __extendhfsf2, $pop1378; FASTISEL-NEXT: i64.trunc_sat_f32_u $push0=, $pop2379; FASTISEL-NEXT: return $pop0380 %a = load half, ptr %p, align 2381 %r = fptoui half %a to i64382 ret i64 %r383}384 385define void @test_uitofp_i64(i64 %a, ptr %p) nounwind {386; ALL-LABEL: test_uitofp_i64:387; ALL: .functype test_uitofp_i64 (i64, i32) -> ()388; ALL-NEXT: # %bb.0:389; ALL-NEXT: local.get $push3=, 1390; ALL-NEXT: local.get $push2=, 0391; ALL-NEXT: f32.convert_i64_u $push0=, $pop2392; ALL-NEXT: call $push1=, __truncsfhf2, $pop0393; ALL-NEXT: i32.store16 0($pop3), $pop1394; ALL-NEXT: return395 %r = uitofp i64 %a to half396 store half %r, ptr %p397 ret void398}399 400define <4 x float> @test_extend32_vec4(ptr %p) nounwind {401; ALL-LABEL: test_extend32_vec4:402; ALL: .functype test_extend32_vec4 (i32, i32) -> ()403; ALL-NEXT: # %bb.0:404; ALL-NEXT: local.get $push9=, 0405; ALL-NEXT: local.get $push8=, 1406; ALL-NEXT: i32.load16_u $push0=, 6($pop8)407; ALL-NEXT: call $push1=, __extendhfsf2, $pop0408; ALL-NEXT: f32.store 12($pop9), $pop1409; ALL-NEXT: local.get $push11=, 0410; ALL-NEXT: local.get $push10=, 1411; ALL-NEXT: i32.load16_u $push2=, 4($pop10)412; ALL-NEXT: call $push3=, __extendhfsf2, $pop2413; ALL-NEXT: f32.store 8($pop11), $pop3414; ALL-NEXT: local.get $push13=, 0415; ALL-NEXT: local.get $push12=, 1416; ALL-NEXT: i32.load16_u $push4=, 2($pop12)417; ALL-NEXT: call $push5=, __extendhfsf2, $pop4418; ALL-NEXT: f32.store 4($pop13), $pop5419; ALL-NEXT: local.get $push15=, 0420; ALL-NEXT: local.get $push14=, 1421; ALL-NEXT: i32.load16_u $push6=, 0($pop14)422; ALL-NEXT: call $push7=, __extendhfsf2, $pop6423; ALL-NEXT: f32.store 0($pop15), $pop7424; ALL-NEXT: return425 %a = load <4 x half>, ptr %p, align 8426 %b = fpext <4 x half> %a to <4 x float>427 ret <4 x float> %b428}429 430define <4 x double> @test_extend64_vec4(ptr %p) nounwind {431; ALL-LABEL: test_extend64_vec4:432; ALL: .functype test_extend64_vec4 (i32, i32) -> ()433; ALL-NEXT: # %bb.0:434; ALL-NEXT: local.get $push13=, 0435; ALL-NEXT: local.get $push12=, 1436; ALL-NEXT: i64.load16_u $push0=, 6($pop12)437; ALL-NEXT: call $push1=, __extendhfsf2, $pop0438; ALL-NEXT: f64.promote_f32 $push2=, $pop1439; ALL-NEXT: f64.store 24($pop13), $pop2440; ALL-NEXT: local.get $push15=, 0441; ALL-NEXT: local.get $push14=, 1442; ALL-NEXT: i64.load16_u $push3=, 4($pop14)443; ALL-NEXT: call $push4=, __extendhfsf2, $pop3444; ALL-NEXT: f64.promote_f32 $push5=, $pop4445; ALL-NEXT: f64.store 16($pop15), $pop5446; ALL-NEXT: local.get $push17=, 0447; ALL-NEXT: local.get $push16=, 1448; ALL-NEXT: i64.load16_u $push6=, 2($pop16)449; ALL-NEXT: call $push7=, __extendhfsf2, $pop6450; ALL-NEXT: f64.promote_f32 $push8=, $pop7451; ALL-NEXT: f64.store 8($pop17), $pop8452; ALL-NEXT: local.get $push19=, 0453; ALL-NEXT: local.get $push18=, 1454; ALL-NEXT: i64.load16_u $push9=, 0($pop18)455; ALL-NEXT: call $push10=, __extendhfsf2, $pop9456; ALL-NEXT: f64.promote_f32 $push11=, $pop10457; ALL-NEXT: f64.store 0($pop19), $pop11458; ALL-NEXT: return459 %a = load <4 x half>, ptr %p, align 8460 %b = fpext <4 x half> %a to <4 x double>461 ret <4 x double> %b462}463 464define void @test_trunc32_vec4(<4 x float> %a, ptr %p) nounwind {465; DEFISEL-LABEL: test_trunc32_vec4:466; DEFISEL: .functype test_trunc32_vec4 (f32, f32, f32, f32, i32) -> ()467; DEFISEL-NEXT: # %bb.0:468; DEFISEL-NEXT: local.get $push5=, 4469; DEFISEL-NEXT: local.get $push4=, 3470; DEFISEL-NEXT: call $push0=, __truncsfhf2, $pop4471; DEFISEL-NEXT: i32.store16 6($pop5), $pop0472; DEFISEL-NEXT: local.get $push7=, 4473; DEFISEL-NEXT: local.get $push6=, 2474; DEFISEL-NEXT: call $push1=, __truncsfhf2, $pop6475; DEFISEL-NEXT: i32.store16 4($pop7), $pop1476; DEFISEL-NEXT: local.get $push9=, 4477; DEFISEL-NEXT: local.get $push8=, 1478; DEFISEL-NEXT: call $push2=, __truncsfhf2, $pop8479; DEFISEL-NEXT: i32.store16 2($pop9), $pop2480; DEFISEL-NEXT: local.get $push11=, 4481; DEFISEL-NEXT: local.get $push10=, 0482; DEFISEL-NEXT: call $push3=, __truncsfhf2, $pop10483; DEFISEL-NEXT: i32.store16 0($pop11), $pop3484; DEFISEL-NEXT: return485;486; FASTISEL-LABEL: test_trunc32_vec4:487; FASTISEL: .functype test_trunc32_vec4 (f32, f32, f32, f32, i32) -> ()488; FASTISEL-NEXT: # %bb.0:489; FASTISEL-NEXT: local.get $push5=, 4490; FASTISEL-NEXT: local.get $push4=, 0491; FASTISEL-NEXT: call $push0=, __truncsfhf2, $pop4492; FASTISEL-NEXT: i32.store16 0($pop5), $pop0493; FASTISEL-NEXT: local.get $push7=, 4494; FASTISEL-NEXT: local.get $push6=, 1495; FASTISEL-NEXT: call $push1=, __truncsfhf2, $pop6496; FASTISEL-NEXT: i32.store16 2($pop7), $pop1497; FASTISEL-NEXT: local.get $push9=, 4498; FASTISEL-NEXT: local.get $push8=, 2499; FASTISEL-NEXT: call $push2=, __truncsfhf2, $pop8500; FASTISEL-NEXT: i32.store16 4($pop9), $pop2501; FASTISEL-NEXT: local.get $push11=, 4502; FASTISEL-NEXT: local.get $push10=, 3503; FASTISEL-NEXT: call $push3=, __truncsfhf2, $pop10504; FASTISEL-NEXT: i32.store16 6($pop11), $pop3505; FASTISEL-NEXT: return506 %v = fptrunc <4 x float> %a to <4 x half>507 store <4 x half> %v, ptr %p508 ret void509}510 511define void @test_trunc64_vec4(<4 x double> %a, ptr %p) nounwind {512; DEFISEL-LABEL: test_trunc64_vec4:513; DEFISEL: .functype test_trunc64_vec4 (f64, f64, f64, f64, i32) -> ()514; DEFISEL-NEXT: # %bb.0:515; DEFISEL-NEXT: local.get $push5=, 4516; DEFISEL-NEXT: local.get $push4=, 3517; DEFISEL-NEXT: call $push0=, __truncdfhf2, $pop4518; DEFISEL-NEXT: i32.store16 6($pop5), $pop0519; DEFISEL-NEXT: local.get $push7=, 4520; DEFISEL-NEXT: local.get $push6=, 2521; DEFISEL-NEXT: call $push1=, __truncdfhf2, $pop6522; DEFISEL-NEXT: i32.store16 4($pop7), $pop1523; DEFISEL-NEXT: local.get $push9=, 4524; DEFISEL-NEXT: local.get $push8=, 1525; DEFISEL-NEXT: call $push2=, __truncdfhf2, $pop8526; DEFISEL-NEXT: i32.store16 2($pop9), $pop2527; DEFISEL-NEXT: local.get $push11=, 4528; DEFISEL-NEXT: local.get $push10=, 0529; DEFISEL-NEXT: call $push3=, __truncdfhf2, $pop10530; DEFISEL-NEXT: i32.store16 0($pop11), $pop3531; DEFISEL-NEXT: return532;533; FASTISEL-LABEL: test_trunc64_vec4:534; FASTISEL: .functype test_trunc64_vec4 (f64, f64, f64, f64, i32) -> ()535; FASTISEL-NEXT: # %bb.0:536; FASTISEL-NEXT: local.get $push5=, 4537; FASTISEL-NEXT: local.get $push4=, 0538; FASTISEL-NEXT: call $push0=, __truncdfhf2, $pop4539; FASTISEL-NEXT: i32.store16 0($pop5), $pop0540; FASTISEL-NEXT: local.get $push7=, 4541; FASTISEL-NEXT: local.get $push6=, 1542; FASTISEL-NEXT: call $push1=, __truncdfhf2, $pop6543; FASTISEL-NEXT: i32.store16 2($pop7), $pop1544; FASTISEL-NEXT: local.get $push9=, 4545; FASTISEL-NEXT: local.get $push8=, 2546; FASTISEL-NEXT: call $push2=, __truncdfhf2, $pop8547; FASTISEL-NEXT: i32.store16 4($pop9), $pop2548; FASTISEL-NEXT: local.get $push11=, 4549; FASTISEL-NEXT: local.get $push10=, 3550; FASTISEL-NEXT: call $push3=, __truncdfhf2, $pop10551; FASTISEL-NEXT: i32.store16 6($pop11), $pop3552; FASTISEL-NEXT: return553 %v = fptrunc <4 x double> %a to <4 x half>554 store <4 x half> %v, ptr %p555 ret void556}557 558define float @test_sitofp_fadd_i32(i32 %a, ptr %b) nounwind {559; DEFISEL-LABEL: test_sitofp_fadd_i32:560; DEFISEL: .functype test_sitofp_fadd_i32 (i32, i32) -> (f32)561; DEFISEL-NEXT: # %bb.0:562; DEFISEL-NEXT: local.get $push6=, 1563; DEFISEL-NEXT: i32.load16_u $push1=, 0($pop6)564; DEFISEL-NEXT: call $push2=, __extendhfsf2, $pop1565; DEFISEL-NEXT: local.get $push7=, 0566; DEFISEL-NEXT: f32.convert_i32_s $push0=, $pop7567; DEFISEL-NEXT: call $push3=, __truncsfhf2, $pop0568; DEFISEL-NEXT: call $push4=, __extendhfsf2, $pop3569; DEFISEL-NEXT: f32.add $push5=, $pop2, $pop4570; DEFISEL-NEXT: return $pop5571;572; FASTISEL-LABEL: test_sitofp_fadd_i32:573; FASTISEL: .functype test_sitofp_fadd_i32 (i32, i32) -> (f32)574; FASTISEL-NEXT: # %bb.0:575; FASTISEL-NEXT: local.get $push6=, 1576; FASTISEL-NEXT: i32.load16_u $push2=, 0($pop6)577; FASTISEL-NEXT: call $push3=, __extendhfsf2, $pop2578; FASTISEL-NEXT: local.get $push7=, 0579; FASTISEL-NEXT: f32.convert_i32_s $push1=, $pop7580; FASTISEL-NEXT: call $push4=, __truncsfhf2, $pop1581; FASTISEL-NEXT: call $push5=, __extendhfsf2, $pop4582; FASTISEL-NEXT: f32.add $push0=, $pop3, $pop5583; FASTISEL-NEXT: return $pop0584 %tmp0 = load half, ptr %b585 %tmp1 = sitofp i32 %a to half586 %tmp2 = fadd half %tmp0, %tmp1587 %tmp3 = fpext half %tmp2 to float588 ret float %tmp3589}590 591define half @chained_fp_ops(half %x) {592; ALL-LABEL: chained_fp_ops:593; ALL: .functype chained_fp_ops (f32) -> (f32)594; ALL-NEXT: # %bb.0: # %start595; ALL-NEXT: local.get $push6=, 0596; ALL-NEXT: call $push0=, __truncsfhf2, $pop6597; ALL-NEXT: call $push5=, __extendhfsf2, $pop0598; ALL-NEXT: local.tee $push4=, 0, $pop5599; ALL-NEXT: local.get $push7=, 0600; ALL-NEXT: f32.add $push1=, $pop4, $pop7601; ALL-NEXT: f32.const $push2=, 0x1p-1602; ALL-NEXT: f32.mul $push3=, $pop1, $pop2603; ALL-NEXT: return $pop3604start:605 %y = fmul half %x, 0xH4000606 %z = fdiv half %y, 0xH4000607 ret half %z608}609 610define half @test_select_cc(half) nounwind {611; ALL-LABEL: test_select_cc:612; ALL: .functype test_select_cc (f32) -> (f32)613; ALL-NEXT: # %bb.0:614; ALL-NEXT: f32.const $push4=, 0x1p0615; ALL-NEXT: f32.const $push0=, 0x0p0616; ALL-NEXT: local.get $push7=, 0617; ALL-NEXT: call $push1=, __truncsfhf2, $pop7618; ALL-NEXT: call $push2=, __extendhfsf2, $pop1619; ALL-NEXT: f32.const $push6=, 0x0p0620; ALL-NEXT: f32.ne $push3=, $pop2, $pop6621; ALL-NEXT: f32.select $push5=, $pop4, $pop0, $pop3622; ALL-NEXT: return $pop5623 %2 = fcmp une half %0, 0xH0000624 %3 = uitofp i1 %2 to half625 ret half %3626}627 628define half @fabs(half %x) nounwind {629; ALL-LABEL: fabs:630; ALL: .functype fabs (f32) -> (f32)631; ALL-NEXT: # %bb.0:632; ALL-NEXT: local.get $push3=, 0633; ALL-NEXT: call $push0=, __truncsfhf2, $pop3634; ALL-NEXT: call $push1=, __extendhfsf2, $pop0635; ALL-NEXT: f32.abs $push2=, $pop1636; ALL-NEXT: return $pop2637 %a = call half @llvm.fabs.f16(half %x)638 ret half %a639}640 641define half @fcopysign(half %x, half %y) nounwind {642; ALL-LABEL: fcopysign:643; ALL: .functype fcopysign (f32, f32) -> (f32)644; ALL-NEXT: # %bb.0:645; ALL-NEXT: local.get $push3=, 0646; ALL-NEXT: call $push0=, __truncsfhf2, $pop3647; ALL-NEXT: call $push1=, __extendhfsf2, $pop0648; ALL-NEXT: local.get $push4=, 1649; ALL-NEXT: f32.copysign $push2=, $pop1, $pop4650; ALL-NEXT: return $pop2651 %a = call half @llvm.copysign.f16(half %x, half %y)652 ret half %a653}654