Re: [V2] RISC-V: Replace not + bitwise_imm with li + bitwise_not

2023-09-29 Thread Jeff Law
On 9/12/23 13:09, Jivan Hakobyan via Gcc-patches wrote: In the case when we have C code like this int foo (int a) { return 100 & ~a; } GCC generates the following instruction sequence foo: not a0,a0 andia0,a0,100 ret This patch replaces that with this sequence

[V2] RISC-V: Replace not + bitwise_imm with li + bitwise_not

2023-09-12 Thread Jivan Hakobyan via Gcc-patches
In the case when we have C code like this int foo (int a) { return 100 & ~a; } GCC generates the following instruction sequence foo: not a0,a0 andia0,a0,100 ret This patch replaces that with this sequence foo: li a5,100 andn a0,a5,a0 ret The profitabili

Re: RISC-V: Replace not + bitwise_imm with li + bitwise_not

2023-09-11 Thread Jeff Law via Gcc-patches
On 9/11/23 13:16, Andrew Waterman via Gcc-patches wrote: Note this is a size-speed tradeoff, as the Zcb extension has a 16-bit-wide C.NOT instruction. Might want to suppress this optimization when Zcb is present and the function is being optimize > for size. Yea, let's gate this on !optimize

Re: RISC-V: Replace not + bitwise_imm with li + bitwise_not

2023-09-11 Thread Andrew Waterman via Gcc-patches
Note this is a size-speed tradeoff, as the Zcb extension has a 16-bit-wide C.NOT instruction. Might want to suppress this optimization when Zcb is present and the function is being optimized for size. On Mon, Sep 11, 2023 at 9:52 AM Jivan Hakobyan via Gcc-patches wrote: > > In the case when we

RISC-V: Replace not + bitwise_imm with li + bitwise_not

2023-09-11 Thread Jivan Hakobyan via Gcc-patches
In the case when we have C code like this int foo (int a) { return 100 & ~a; } GCC generates the following instruction sequence foo: not a0,a0 andia0,a0,100 ret This patch replaces that with this sequence foo: li a5,100 andn a0,a5,a0 ret The profitabili