Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Philipp Tomsich
On Thu, 17 Nov 2022 at 19:56, Andrew Waterman wrote: > > On Thu, Nov 17, 2022 at 10:52 AM Philipp Tomsich > wrote: > > > > On Thu, 17 Nov 2022 at 19:33, Andrew Waterman wrote: > > > > > > Am I wrong to worry that this will increase dynamic instruction count > > > when used in a loop? The

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Philipp Tomsich
On Thu, 17 Nov 2022 at 19:28, Andrew Pinski wrote: > > On Thu, Nov 17, 2022 at 10:25 AM Andrew Pinski wrote: > > > > On Sun, Nov 13, 2022 at 12:51 PM Philipp Tomsich > > wrote: > > > > > > Use Zbs when generating a sequence for "if ((a & twobits) == singlebit) > > > ..." > > > that can be

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Andrew Waterman
On Thu, Nov 17, 2022 at 10:52 AM Philipp Tomsich wrote: > > On Thu, 17 Nov 2022 at 19:33, Andrew Waterman wrote: > > > > Am I wrong to worry that this will increase dynamic instruction count > > when used in a loop? The obvious code is more efficient when the > > constant loads can be hoisted

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Philipp Tomsich
On Thu, 17 Nov 2022 at 19:33, Andrew Waterman wrote: > > Am I wrong to worry that this will increase dynamic instruction count > when used in a loop? The obvious code is more efficient when the > constant loads can be hoisted out of a loop. Or does the cost model > account for this somehow?

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Andrew Waterman
Am I wrong to worry that this will increase dynamic instruction count when used in a loop? The obvious code is more efficient when the constant loads can be hoisted out of a loop. Or does the cost model account for this somehow? On Sun, Nov 13, 2022 at 12:50 PM Philipp Tomsich wrote: > > Use

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Andrew Pinski via Gcc-patches
On Thu, Nov 17, 2022 at 10:25 AM Andrew Pinski wrote: > > On Sun, Nov 13, 2022 at 12:51 PM Philipp Tomsich > wrote: > > > > Use Zbs when generating a sequence for "if ((a & twobits) == singlebit) ..." > > that can be expressed as bexti + bexti + andn. > > Can't you also handle if ((a & twobits)

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Andrew Pinski via Gcc-patches
On Sun, Nov 13, 2022 at 12:51 PM Philipp Tomsich wrote: > > Use Zbs when generating a sequence for "if ((a & twobits) == singlebit) ..." > that can be expressed as bexti + bexti + andn. Can't you also handle if ((a & twobits) == 0) case doing a similar thing. That is: two bexti + and and then

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Philipp Tomsich
On Thu, 17 Nov 2022 at 17:39, Jeff Law wrote: > > > On 11/17/22 08:12, Philipp Tomsich wrote: > > > > This serves as an assertion only, as that case is non-sensical and > > will be optimized away by earlier passes (as "a & C == T" with C and T > > sharing no bits will always be false). > > IFAIK

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Jeff Law via Gcc-patches
On 11/17/22 08:12, Philipp Tomsich wrote: This serves as an assertion only, as that case is non-sensical and will be optimized away by earlier passes (as "a & C == T" with C and T sharing no bits will always be false). IFAIK the preceding transforms should always clean such a check up, but we

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Philipp Tomsich
On Thu, 17 Nov 2022 at 15:58, Jeff Law wrote: > > > On 11/13/22 13:48, Philipp Tomsich wrote: > > Use Zbs when generating a sequence for "if ((a & twobits) == singlebit) ..." > > that can be expressed as bexti + bexti + andn. > > > > gcc/ChangeLog: > > > > * config/riscv/bitmanip.md > >

Re: [PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-17 Thread Jeff Law via Gcc-patches
On 11/13/22 13:48, Philipp Tomsich wrote: Use Zbs when generating a sequence for "if ((a & twobits) == singlebit) ..." that can be expressed as bexti + bexti + andn. gcc/ChangeLog: * config/riscv/bitmanip.md (*branch_mask_twobits_equals_singlebit): Handle "if ((a & T) == C)"

[PATCH] RISC-V: Handle "(a & twobits) == singlebit" in branches using Zbs

2022-11-13 Thread Philipp Tomsich
Use Zbs when generating a sequence for "if ((a & twobits) == singlebit) ..." that can be expressed as bexti + bexti + andn. gcc/ChangeLog: * config/riscv/bitmanip.md (*branch_mask_twobits_equals_singlebit): Handle "if ((a & T) == C)" using Zbs, when T has 2 bits set and C has