diff mbox series

[v1,2/2] fpu/softfloat: raise float_invalid for NaN in float_to_int

Message ID 20180412115838.10208-3-alex.bennee@linaro.org
State New
Headers show
Series Softfloat Fixes for 2.12 | expand

Commit Message

Alex Bennée April 12, 2018, 11:58 a.m. UTC
Fixes https://bugs.launchpad.net/qemu/+bug/1759264

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
---
 fpu/softfloat.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Peter Maydell April 12, 2018, 12:26 p.m. UTC | #1
On 12 April 2018 at 12:58, Alex Bennée <alex.bennee@linaro.org> wrote:
> Fixes https://bugs.launchpad.net/qemu/+bug/1759264
>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
> ---
>  fpu/softfloat.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
> index 9b99aa6ec8..ddc77c273c 100644
> --- a/fpu/softfloat.c
> +++ b/fpu/softfloat.c
> @@ -1344,6 +1344,7 @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode,
>      case float_class_qnan:
>      case float_class_dnan:
>      case float_class_msnan:
> +        s->float_exception_flags = orig_flags | float_flag_invalid;
>          return max;
>      case float_class_inf:
>          return p.sign ? min : max;

Don't we also need to raise the Invalid flag for float_class_inf ?

In both cases, this is fixing a regression introduced in
commit ab52f973a50, I think.

thanks
-- PMM
Bastian Koppelmann April 12, 2018, 12:34 p.m. UTC | #2
On 04/12/2018 02:26 PM, Peter Maydell wrote:
> On 12 April 2018 at 12:58, Alex Bennée <alex.bennee@linaro.org> wrote:
>> Fixes https://bugs.launchpad.net/qemu/+bug/1759264
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
>> ---
>>  fpu/softfloat.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
>> index 9b99aa6ec8..ddc77c273c 100644
>> --- a/fpu/softfloat.c
>> +++ b/fpu/softfloat.c
>> @@ -1344,6 +1344,7 @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode,
>>      case float_class_qnan:
>>      case float_class_dnan:
>>      case float_class_msnan:
>> +        s->float_exception_flags = orig_flags | float_flag_invalid;
>>          return max;
>>      case float_class_inf:
>>          return p.sign ? min : max;
> 
> Don't we also need to raise the Invalid flag for float_class_inf ?
> 

Yup, as mentioned in the bug report.

Cheers,
Bastian
Alex Bennée April 12, 2018, 1:23 p.m. UTC | #3
Peter Maydell <peter.maydell@linaro.org> writes:

> On 12 April 2018 at 12:58, Alex Bennée <alex.bennee@linaro.org> wrote:
>> Fixes https://bugs.launchpad.net/qemu/+bug/1759264
>>
>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>> Cc: Bastian Koppelmann <kbastian@mail.uni-paderborn.de>
>> ---
>>  fpu/softfloat.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/fpu/softfloat.c b/fpu/softfloat.c
>> index 9b99aa6ec8..ddc77c273c 100644
>> --- a/fpu/softfloat.c
>> +++ b/fpu/softfloat.c
>> @@ -1344,6 +1344,7 @@ static int64_t round_to_int_and_pack(FloatParts in, int rmode,
>>      case float_class_qnan:
>>      case float_class_dnan:
>>      case float_class_msnan:
>> +        s->float_exception_flags = orig_flags | float_flag_invalid;
>>          return max;
>>      case float_class_inf:
>>          return p.sign ? min : max;
>
> Don't we also need to raise the Invalid flag for float_class_inf ?
>
> In both cases, this is fixing a regression introduced in
> commit ab52f973a50, I think.

And I guess the round_to_uint_and_pack as well which doesn't handle the
input inf case.

>
> thanks
> -- PMM


--
Alex Bennée
diff mbox series

Patch

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 9b99aa6ec8..ddc77c273c 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -1344,6 +1344,7 @@  static int64_t round_to_int_and_pack(FloatParts in, int rmode,
     case float_class_qnan:
     case float_class_dnan:
     case float_class_msnan:
+        s->float_exception_flags = orig_flags | float_flag_invalid;
         return max;
     case float_class_inf:
         return p.sign ? min : max;