@@ -58,6 +58,8 @@ static const aot_intrinsic g_intrinsic_mapping[] = {
5858 { "i32_trunc_f64_u" , "aot_intrinsic_f64_to_u32" , AOT_INTRINSIC_FLAG_F64_TO_U32 },
5959 { "i32_trunc_f64_s" , "aot_intrinsic_f64_to_i32" , AOT_INTRINSIC_FLAG_F64_TO_I32 },
6060 { "i64_trunc_f64_u" , "aot_intrinsic_f64_to_u64" , AOT_INTRINSIC_FLAG_F64_TO_U64 },
61+ { "i64_trunc_f32_s" , "aot_intrinsic_f32_to_i64" , AOT_INTRINSIC_FLAG_F32_TO_I64 },
62+ { "i64_trunc_f32_u" , "aot_intrinsic_f32_to_u64" , AOT_INTRINSIC_FLAG_F32_TO_U64 },
6163 { "i64_trunc_f64_s" , "aot_intrinsic_f64_to_i64" , AOT_INTRINSIC_FLAG_F64_TO_I64 },
6264 { "f32_demote_f64" , "aot_intrinsic_f64_to_f32" , AOT_INTRINSIC_FLAG_F64_TO_F32 },
6365 { "f64_promote_f32" , "aot_intrinsic_f32_to_f64" , AOT_INTRINSIC_FLAG_F32_TO_F64 },
@@ -134,7 +136,7 @@ aot_intrinsic_fdiv_f64(float64 a, float64 b)
134136float32
135137aot_intrinsic_fabs_f32 (float32 a )
136138{
137- return ( float32 ) fabs (a );
139+ return fabsf (a );
138140}
139141
140142float64
@@ -146,7 +148,7 @@ aot_intrinsic_fabs_f64(float64 a)
146148float32
147149aot_intrinsic_ceil_f32 (float32 a )
148150{
149- return ( float32 ) ceilf (a );
151+ return ceilf (a );
150152}
151153
152154float64
@@ -158,7 +160,7 @@ aot_intrinsic_ceil_f64(float64 a)
158160float32
159161aot_intrinsic_floor_f32 (float32 a )
160162{
161- return ( float32 ) floorf (a );
163+ return floorf (a );
162164}
163165
164166float64
@@ -170,7 +172,7 @@ aot_intrinsic_floor_f64(float64 a)
170172float32
171173aot_intrinsic_trunc_f32 (float32 a )
172174{
173- return ( float32 ) trunc (a );
175+ return truncf (a );
174176}
175177
176178float64
@@ -182,7 +184,7 @@ aot_intrinsic_trunc_f64(float64 a)
182184float32
183185aot_intrinsic_rint_f32 (float32 a )
184186{
185- return ( float32 ) rint (a );
187+ return rintf (a );
186188}
187189
188190float64
@@ -194,7 +196,7 @@ aot_intrinsic_rint_f64(float64 a)
194196float32
195197aot_intrinsic_sqrt_f32 (float32 a )
196198{
197- return ( float32 ) sqrt (a );
199+ return sqrtf (a );
198200}
199201
200202float64
@@ -206,7 +208,7 @@ aot_intrinsic_sqrt_f64(float64 a)
206208float32
207209aot_intrinsic_copysign_f32 (float32 a , float32 b )
208210{
209- return signbit (b ) ? ( float32 ) - fabs (a ) : ( float32 ) fabs (a );
211+ return signbit (b ) ? - fabsf (a ) : fabsf (a );
210212}
211213
212214float64
@@ -218,41 +220,45 @@ aot_intrinsic_copysign_f64(float64 a, float64 b)
218220float32
219221aot_intrinsic_fmin_f32 (float32 a , float32 b )
220222{
221- if (isnan (a ))
222- return a ;
223- else if (isnan ( b ) )
224- return b ;
223+ if (isnan (a ) || isnan ( b ) )
224+ return NAN ;
225+ else if (a == 0 && a == b )
226+ return signbit ( a ) ? a : b ;
225227 else
226- return ( float32 ) fmin ( a , b ) ;
228+ return a > b ? b : a ;
227229}
228230
229231float64
230232aot_intrinsic_fmin_f64 (float64 a , float64 b )
231233{
232- float64 c = fmin (a , b );
233- if (c == 0 && a == b )
234+ if (isnan (a ) || isnan (b ))
235+ return NAN ;
236+ else if (a == 0 && a == b )
234237 return signbit (a ) ? a : b ;
235- return c ;
238+ else
239+ return a > b ? b : a ;
236240}
237241
238242float32
239243aot_intrinsic_fmax_f32 (float32 a , float32 b )
240244{
241- if (isnan (a ))
242- return a ;
243- else if (isnan ( b ) )
244- return b ;
245+ if (isnan (a ) || isnan ( b ) )
246+ return NAN ;
247+ else if (a == 0 && a == b )
248+ return signbit ( a ) ? b : a ;
245249 else
246- return ( float32 ) fmax ( a , b ) ;
250+ return a > b ? a : b ;
247251}
248252
249253float64
250254aot_intrinsic_fmax_f64 (float64 a , float64 b )
251255{
252- float64 c = fmax (a , b );
253- if (c == 0 && a == b )
256+ if (isnan (a ) || isnan (b ))
257+ return NAN ;
258+ else if (a == 0 && a == b )
254259 return signbit (a ) ? b : a ;
255- return c ;
260+ else
261+ return a > b ? a : b ;
256262}
257263
258264uint32
@@ -442,7 +448,7 @@ aot_intrinsic_f32_cmp(AOTFloatCond cond, float32 lhs, float32 rhs)
442448{
443449 switch (cond ) {
444450 case FLOAT_EQ :
445- return ( float32 ) fabs ( lhs - rhs ) <= WA_FLT_EPSILON ? 1 : 0 ;
451+ return lhs == rhs ? 1 : 0 ;
446452
447453 case FLOAT_LT :
448454 return lhs < rhs ? 1 : 0 ;
@@ -473,7 +479,7 @@ aot_intrinsic_f64_cmp(AOTFloatCond cond, float64 lhs, float64 rhs)
473479{
474480 switch (cond ) {
475481 case FLOAT_EQ :
476- return fabs ( lhs - rhs ) <= WA_DBL_EPSILON ? 1 : 0 ;
482+ return lhs == rhs ? 1 : 0 ;
477483
478484 case FLOAT_LT :
479485 return lhs < rhs ? 1 : 0 ;
@@ -631,6 +637,12 @@ add_f64_common_intrinsics(AOTCompContext *comp_ctx)
631637 add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_FADD );
632638 add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_FSUB );
633639 add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_FMUL );
640+ add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_MIN );
641+ add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_MAX );
642+ add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_CEIL );
643+ add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_FLOOR );
644+ add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_TRUNC );
645+ add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_RINT );
634646 add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_FDIV );
635647 add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_SQRT );
636648 add_intrinsic_capability (comp_ctx , AOT_INTRINSIC_FLAG_F64_CMP );
0 commit comments