@@ -421,45 +421,19 @@ fn codegen_float_intrinsic_call<'tcx>(
421421 let layout = fx. layout_of ( ty) ;
422422 // FIXME(bytecodealliance/wasmtime#8312): Use native Cranelift operations
423423 // for `f16` and `f128` once the lowerings have been implemented in Cranelift.
424- let res = match intrinsic {
425- sym:: fmaf16 | sym:: fmuladdf16 => {
426- CValue :: by_val ( codegen_f16_f128:: fma_f16 ( fx, args[ 0 ] , args[ 1 ] , args[ 2 ] ) , layout)
427- }
424+ let val = match intrinsic {
425+ sym:: fmaf16 | sym:: fmuladdf16 => codegen_f16_f128:: fma_f16 ( fx, args[ 0 ] , args[ 1 ] , args[ 2 ] ) ,
428426 sym:: fmaf32 | sym:: fmaf64 | sym:: fmuladdf32 | sym:: fmuladdf64 => {
429- CValue :: by_val ( fx. bcx . ins ( ) . fma ( args[ 0 ] , args[ 1 ] , args[ 2 ] ) , layout)
430- }
431- sym:: copysignf16 => {
432- CValue :: by_val ( codegen_f16_f128:: copysign_f16 ( fx, args[ 0 ] , args[ 1 ] ) , layout)
433- }
434- sym:: copysignf128 => {
435- CValue :: by_val ( codegen_f16_f128:: copysign_f128 ( fx, args[ 0 ] , args[ 1 ] ) , layout)
436- }
437- sym:: copysignf32 | sym:: copysignf64 => {
438- CValue :: by_val ( fx. bcx . ins ( ) . fcopysign ( args[ 0 ] , args[ 1 ] ) , layout)
439- }
440- sym:: floorf32
441- | sym:: floorf64
442- | sym:: ceilf32
443- | sym:: ceilf64
444- | sym:: truncf32
445- | sym:: truncf64
446- | sym:: round_ties_even_f32
447- | sym:: round_ties_even_f64
448- | sym:: sqrtf32
449- | sym:: sqrtf64 => {
450- let val = match intrinsic {
451- sym:: floorf32 | sym:: floorf64 => fx. bcx . ins ( ) . floor ( args[ 0 ] ) ,
452- sym:: ceilf32 | sym:: ceilf64 => fx. bcx . ins ( ) . ceil ( args[ 0 ] ) ,
453- sym:: truncf32 | sym:: truncf64 => fx. bcx . ins ( ) . trunc ( args[ 0 ] ) ,
454- sym:: round_ties_even_f32 | sym:: round_ties_even_f64 => {
455- fx. bcx . ins ( ) . nearest ( args[ 0 ] )
456- }
457- sym:: sqrtf32 | sym:: sqrtf64 => fx. bcx . ins ( ) . sqrt ( args[ 0 ] ) ,
458- _ => unreachable ! ( ) ,
459- } ;
460-
461- CValue :: by_val ( val, layout)
427+ fx. bcx . ins ( ) . fma ( args[ 0 ] , args[ 1 ] , args[ 2 ] )
462428 }
429+ sym:: copysignf16 => codegen_f16_f128:: copysign_f16 ( fx, args[ 0 ] , args[ 1 ] ) ,
430+ sym:: copysignf128 => codegen_f16_f128:: copysign_f128 ( fx, args[ 0 ] , args[ 1 ] ) ,
431+ sym:: copysignf32 | sym:: copysignf64 => fx. bcx . ins ( ) . fcopysign ( args[ 0 ] , args[ 1 ] ) ,
432+ sym:: floorf32 | sym:: floorf64 => fx. bcx . ins ( ) . floor ( args[ 0 ] ) ,
433+ sym:: ceilf32 | sym:: ceilf64 => fx. bcx . ins ( ) . ceil ( args[ 0 ] ) ,
434+ sym:: truncf32 | sym:: truncf64 => fx. bcx . ins ( ) . trunc ( args[ 0 ] ) ,
435+ sym:: round_ties_even_f32 | sym:: round_ties_even_f64 => fx. bcx . ins ( ) . nearest ( args[ 0 ] ) ,
436+ sym:: sqrtf32 | sym:: sqrtf64 => fx. bcx . ins ( ) . sqrt ( args[ 0 ] ) ,
463437
464438 // These intrinsics aren't supported natively by Cranelift.
465439 // Lower them to a libcall.
@@ -474,12 +448,11 @@ fn codegen_float_intrinsic_call<'tcx>(
474448 let input_tys: Vec < _ > =
475449 vec ! [ AbiParam :: new( clif_ty) , lib_call_arg_param( fx. tcx, types:: I32 , true ) ] ;
476450 let ret_val = fx. lib_call ( name, input_tys, vec ! [ AbiParam :: new( clif_ty) ] , args) [ 0 ] ;
477- let ret_val = if intrinsic == sym:: powif16 {
451+ if intrinsic == sym:: powif16 {
478452 codegen_f16_f128:: f32_to_f16 ( fx, ret_val)
479453 } else {
480454 ret_val
481- } ;
482- CValue :: by_val ( ret_val, fx. layout_of ( ty) )
455+ }
483456 }
484457 sym:: powf16 => {
485458 // FIXME(f16_f128): Rust `compiler-builtins` doesn't export `powf16` yet.
@@ -491,15 +464,15 @@ fn codegen_float_intrinsic_call<'tcx>(
491464 vec ! [ AbiParam :: new( types:: F32 ) ] ,
492465 & [ x, y] ,
493466 ) [ 0 ] ;
494- CValue :: by_val ( codegen_f16_f128:: f32_to_f16 ( fx, ret_val) , fx . layout_of ( ty ) )
467+ codegen_f16_f128:: f32_to_f16 ( fx, ret_val)
495468 }
496469 _ => {
497470 let input_tys: Vec < _ > = args. iter ( ) . map ( |_| AbiParam :: new ( clif_ty) ) . collect ( ) ;
498- let ret_val = fx. lib_call ( name, input_tys, vec ! [ AbiParam :: new( clif_ty) ] , args) [ 0 ] ;
499- CValue :: by_val ( ret_val, fx. layout_of ( ty) )
471+ fx. lib_call ( name, input_tys, vec ! [ AbiParam :: new( clif_ty) ] , args) [ 0 ]
500472 }
501473 } ;
502474
475+ let res = CValue :: by_val ( val, layout) ;
503476 ret. write_cvalue ( fx, res) ;
504477
505478 true
0 commit comments