[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v5 11/60] target/riscv: vector integer add-with-carry / subtr
From: |
Richard Henderson |
Subject: |
Re: [PATCH v5 11/60] target/riscv: vector integer add-with-carry / subtract-with-borrow instructions |
Date: |
Fri, 13 Mar 2020 22:58:53 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
On 3/12/20 7:58 AM, LIU Zhiwei wrote:
> +#define DO_MADC(N, M, C) ((__typeof(N))(N + M + C) < N ? 1 : 0)
Incorrect. E.g N = 1, M = UINT_MAX, C = 1, adds to 1, which is not less than
N, despite the carry-out.
You want
C ? N + M <= N : N + M < N
> +#define DO_MSBC(N, M, C) ((__typeof(N))(N - M - C) > N ? 1 : 0)
Similarly
C ? N <= M : N < M
r~
- [PATCH v5 08/60] target/riscv: add vector amo operations, (continued)
- [PATCH v5 08/60] target/riscv: add vector amo operations, LIU Zhiwei, 2020/03/12
- [PATCH v5 09/60] target/riscv: vector single-width integer add and subtract, LIU Zhiwei, 2020/03/12
- [PATCH v5 10/60] target/riscv: vector widening integer add and subtract, LIU Zhiwei, 2020/03/12
- [PATCH v5 11/60] target/riscv: vector integer add-with-carry / subtract-with-borrow instructions, LIU Zhiwei, 2020/03/12
- Re: [PATCH v5 11/60] target/riscv: vector integer add-with-carry / subtract-with-borrow instructions,
Richard Henderson <=
- [PATCH v5 12/60] target/riscv: vector bitwise logical instructions, LIU Zhiwei, 2020/03/12
- [PATCH v5 13/60] target/riscv: vector single-width bit shift instructions, LIU Zhiwei, 2020/03/12
- [PATCH v5 14/60] target/riscv: vector narrowing integer right shift instructions, LIU Zhiwei, 2020/03/12
- [PATCH v5 15/60] target/riscv: vector integer comparison instructions, LIU Zhiwei, 2020/03/12