@@ -38,47 +38,47 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
3838 for i in 0 ..dest_len {
3939 let op = this. read_immediate ( & this. project_index ( & op, i) ?) ?;
4040 let dest = this. project_index ( & dest, i) ?;
41- let ty:: Float ( float_ty) = op. layout . ty . kind ( ) else {
42- span_bug ! ( this. cur_span( ) , "{} operand is not a float" , intrinsic_name)
43- } ;
44- // Using host floats except for sqrt (but it's fine, these operations do not
45- // have guaranteed precision).
41+ let ty:: Float ( float_ty) = op. layout . ty . kind ( ) else {
42+ span_bug ! ( this. cur_span( ) , "{} operand is not a float" , intrinsic_name)
43+ } ;
44+ // Using host floats except for sqrt (but it's fine, these operations do not
45+ // have guaranteed precision).
4646 let val = match float_ty {
47- FloatTy :: F16 => unimplemented ! ( "f16_f128" ) ,
48- FloatTy :: F32 => {
49- let f = op. to_scalar ( ) . to_f32 ( ) ?;
47+ FloatTy :: F16 => unimplemented ! ( "f16_f128" ) ,
48+ FloatTy :: F32 => {
49+ let f = op. to_scalar ( ) . to_f32 ( ) ?;
5050 let res = match intrinsic_name {
51- "fsqrt" => math:: sqrt ( f) ,
52- "fsin" => f. to_host ( ) . sin ( ) . to_soft ( ) ,
53- "fcos" => f. to_host ( ) . cos ( ) . to_soft ( ) ,
54- "fexp" => f. to_host ( ) . exp ( ) . to_soft ( ) ,
55- "fexp2" => f. to_host ( ) . exp2 ( ) . to_soft ( ) ,
56- "flog" => f. to_host ( ) . ln ( ) . to_soft ( ) ,
57- "flog2" => f. to_host ( ) . log2 ( ) . to_soft ( ) ,
58- "flog10" => f. to_host ( ) . log10 ( ) . to_soft ( ) ,
59- _ => bug ! ( ) ,
60- } ;
61- let res = this. adjust_nan ( res, & [ f] ) ;
62- Scalar :: from ( res)
63- }
64- FloatTy :: F64 => {
65- let f = op. to_scalar ( ) . to_f64 ( ) ?;
51+ "fsqrt" => math:: sqrt ( f) ,
52+ "fsin" => f. to_host ( ) . sin ( ) . to_soft ( ) ,
53+ "fcos" => f. to_host ( ) . cos ( ) . to_soft ( ) ,
54+ "fexp" => f. to_host ( ) . exp ( ) . to_soft ( ) ,
55+ "fexp2" => f. to_host ( ) . exp2 ( ) . to_soft ( ) ,
56+ "flog" => f. to_host ( ) . ln ( ) . to_soft ( ) ,
57+ "flog2" => f. to_host ( ) . log2 ( ) . to_soft ( ) ,
58+ "flog10" => f. to_host ( ) . log10 ( ) . to_soft ( ) ,
59+ _ => bug ! ( ) ,
60+ } ;
61+ let res = this. adjust_nan ( res, & [ f] ) ;
62+ Scalar :: from ( res)
63+ }
64+ FloatTy :: F64 => {
65+ let f = op. to_scalar ( ) . to_f64 ( ) ?;
6666 let res = match intrinsic_name {
67- "fsqrt" => math:: sqrt ( f) ,
68- "fsin" => f. to_host ( ) . sin ( ) . to_soft ( ) ,
69- "fcos" => f. to_host ( ) . cos ( ) . to_soft ( ) ,
70- "fexp" => f. to_host ( ) . exp ( ) . to_soft ( ) ,
71- "fexp2" => f. to_host ( ) . exp2 ( ) . to_soft ( ) ,
72- "flog" => f. to_host ( ) . ln ( ) . to_soft ( ) ,
73- "flog2" => f. to_host ( ) . log2 ( ) . to_soft ( ) ,
74- "flog10" => f. to_host ( ) . log10 ( ) . to_soft ( ) ,
75- _ => bug ! ( ) ,
76- } ;
77- let res = this. adjust_nan ( res, & [ f] ) ;
78- Scalar :: from ( res)
79- }
80- FloatTy :: F128 => unimplemented ! ( "f16_f128" ) ,
67+ "fsqrt" => math:: sqrt ( f) ,
68+ "fsin" => f. to_host ( ) . sin ( ) . to_soft ( ) ,
69+ "fcos" => f. to_host ( ) . cos ( ) . to_soft ( ) ,
70+ "fexp" => f. to_host ( ) . exp ( ) . to_soft ( ) ,
71+ "fexp2" => f. to_host ( ) . exp2 ( ) . to_soft ( ) ,
72+ "flog" => f. to_host ( ) . ln ( ) . to_soft ( ) ,
73+ "flog2" => f. to_host ( ) . log2 ( ) . to_soft ( ) ,
74+ "flog10" => f. to_host ( ) . log10 ( ) . to_soft ( ) ,
75+ _ => bug ! ( ) ,
8176 } ;
77+ let res = this. adjust_nan ( res, & [ f] ) ;
78+ Scalar :: from ( res)
79+ }
80+ FloatTy :: F128 => unimplemented ! ( "f16_f128" ) ,
81+ } ;
8282
8383 this. write_scalar ( val, & dest) ?;
8484 }
0 commit comments