[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 03/38] target/riscv: Fixup saturate subtract function
From: |
Alistair Francis |
Subject: |
Re: [PATCH 03/38] target/riscv: Fixup saturate subtract function |
Date: |
Tue, 9 Mar 2021 09:11:26 -0500 |
On Fri, Feb 12, 2021 at 10:10 AM LIU Zhiwei <zhiwei_liu@c-sky.com> wrote:
>
> The overflow predication ((a - b) ^ a) & (a ^ b) & INT64_MIN is right.
> However, when the predication is ture and a is 0, it should return maximum.
>
> Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> target/riscv/vector_helper.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/target/riscv/vector_helper.c b/target/riscv/vector_helper.c
> index 9371d70f6b..9786f630b4 100644
> --- a/target/riscv/vector_helper.c
> +++ b/target/riscv/vector_helper.c
> @@ -2425,7 +2425,7 @@ int8_t ssub8(CPURISCVState *env, int vxrm, int8_t a,
> int8_t b)
> {
> int8_t res = a - b;
> if ((res ^ a) & (a ^ b) & INT8_MIN) {
> - res = a > 0 ? INT8_MAX : INT8_MIN;
> + res = a >= 0 ? INT8_MAX : INT8_MIN;
> env->vxsat = 0x1;
> }
> return res;
> @@ -2435,7 +2435,7 @@ int16_t ssub16(CPURISCVState *env, int vxrm, int16_t a,
> int16_t b)
> {
> int16_t res = a - b;
> if ((res ^ a) & (a ^ b) & INT16_MIN) {
> - res = a > 0 ? INT16_MAX : INT16_MIN;
> + res = a >= 0 ? INT16_MAX : INT16_MIN;
> env->vxsat = 0x1;
> }
> return res;
> @@ -2445,7 +2445,7 @@ int32_t ssub32(CPURISCVState *env, int vxrm, int32_t a,
> int32_t b)
> {
> int32_t res = a - b;
> if ((res ^ a) & (a ^ b) & INT32_MIN) {
> - res = a > 0 ? INT32_MAX : INT32_MIN;
> + res = a >= 0 ? INT32_MAX : INT32_MIN;
> env->vxsat = 0x1;
> }
> return res;
> @@ -2455,7 +2455,7 @@ int64_t ssub64(CPURISCVState *env, int vxrm, int64_t a,
> int64_t b)
> {
> int64_t res = a - b;
> if ((res ^ a) & (a ^ b) & INT64_MIN) {
> - res = a > 0 ? INT64_MAX : INT64_MIN;
> + res = a >= 0 ? INT64_MAX : INT64_MIN;
> env->vxsat = 0x1;
> }
> return res;
> --
> 2.17.1
>
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: [PATCH 03/38] target/riscv: Fixup saturate subtract function,
Alistair Francis <=