|
From: | Richard Henderson |
Subject: | Re: [PATCH 04/10] target/tricore: Implement FTOU insn |
Date: | Sat, 26 Aug 2023 21:50:51 -0700 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
On 8/26/23 09:02, Bastian Koppelmann wrote:
+uint32_t helper_ftou(CPUTriCoreState *env, uint32_t arg) +{ + float32 f_arg = make_float32(arg); + uint32_t result; + int32_t flags = 0; + + if (float32_is_any_nan(f_arg)) { + result = 0; + flags |= float_flag_invalid; + } else if (float32_lt_quiet(f_arg, 0, &env->fp_status)) { + result = 0; + flags = float_flag_invalid; + } else { + result = float32_to_uint32(f_arg, &env->fp_status); + flags = f_get_excp_flags(env); + }
You should allow softfloat to diagnose the special cases, and negative -> 0 is standard behaviour. Therefore:
result = float32_to_uint32(f_arg, status); flags = f_get_excp_flags(); if (flags) { if ((flags & float_flag_invalid) && !(get_float_exception_flags() & float_flag_invalid_cvti)) { /* invalid without cvti is nan input */ result = 0; } f_update_psw_flags(...); } else { fs = 0; } r~
[Prev in Thread] | Current Thread | [Next in Thread] |