From: Jeff Law <jeffreyalaw@gmail.com>
To: Philipp Tomsich <philipp.tomsich@vrull.eu>, gcc-patches@gcc.gnu.org
Cc: Vineet Gupta <vineetg@rivosinc.com>,
Kito Cheng <kito.cheng@gmail.com>,
Christoph Muellner <christoph.muellner@vrull.eu>,
Jeff Law <jlaw@ventanamicro.com>,
Palmer Dabbelt <palmer@rivosinc.com>
Subject: Re: [PATCH] RISC-V: Split "(a & (1UL << bitno)) ? 0 : -1" to bext + addi
Date: Tue, 15 Nov 2022 10:25:40 -0700 [thread overview]
Message-ID: <391fc4c2-9817-5e36-643c-b32fc635f6dd@gmail.com> (raw)
In-Reply-To: <20221113204840.4062092-1-philipp.tomsich@vrull.eu>
On 11/13/22 13:48, Philipp Tomsich wrote:
> For a straightforward application of bext for the following function
> long bext64(long a, char bitno)
> {
> return (a & (1UL << bitno)) ? 0 : -1;
> }
> we generate
> srl a0,a0,a1 # 7 [c=4 l=4] lshrdi3
> andi a0,a0,1 # 8 [c=4 l=4] anddi3/1
> addi a0,a0,-1 # 14 [c=4 l=4] adddi3/1
> due to the following failed match at combine time:
> (set (reg:DI 82)
> (zero_extract:DI (reg:DI 83)
> (const_int 1 [0x1])
> (reg:DI 84)))
>
> The existing pattern for bext requires the 3rd argument to
> zero_extract to be a QImode register wrapped in a zero_extension.
> This adds an additional pattern that allows an Xmode argument.
>
> With this change, the testcase compiles to
> bext a0,a0,a1 # 8 [c=4 l=4] *bextdi
> addi a0,a0,-1 # 14 [c=4 l=4] adddi3/1
>
> gcc/ChangeLog:
>
> * config/riscv/bitmanip.md (*bext<mode>): Add an additional
> pattern that allows the 3rd argument to zero_extract to be
> an Xmode register operand.
>
> gcc/testsuite/ChangeLog:
>
> * gcc.target/riscv/zbs-bext.c: Add testcases.
> * gcc.target/riscv/zbs-bexti.c: Add testcases.
It's fairly common to want variants with extraction as well as a simple
register operand. The biggest concern is typically around
SHIFT_COUNT_TRUNCATED, but given we already have an extract variant
y'all should have already addressed concerns around SHIFT_COUNT_TRUNCATED.
OK.
jeff
next prev parent reply other threads:[~2022-11-15 17:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-13 20:48 Philipp Tomsich
2022-11-15 17:25 ` Jeff Law [this message]
2022-11-16 20:01 ` Philipp Tomsich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=391fc4c2-9817-5e36-643c-b32fc635f6dd@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=christoph.muellner@vrull.eu \
--cc=gcc-patches@gcc.gnu.org \
--cc=jlaw@ventanamicro.com \
--cc=kito.cheng@gmail.com \
--cc=palmer@rivosinc.com \
--cc=philipp.tomsich@vrull.eu \
--cc=vineetg@rivosinc.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).