public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Philipp Tomsich <philipp.tomsich@vrull.eu>, gcc-patches@gcc.gnu.org
Cc: Kito Cheng <kito.cheng@gmail.com>,
	Christoph Muellner <christoph.muellner@vrull.eu>,
	Vineet Gupta <vineetg@rivosinc.com>,
	Jeff Law <jlaw@ventanamicro.com>,
	Palmer Dabbelt <palmer@rivosinc.com>
Subject: Re: [PATCH] RISC-V: bitmanip: use bexti for "(a & (1 << BIT_NO)) ? 0 : -1"
Date: Thu, 17 Nov 2022 07:43:42 -0700	[thread overview]
Message-ID: <9b0f6fb5-a2e6-3064-5c77-f3357a0a3344@gmail.com> (raw)
In-Reply-To: <20221108195547.2701347-1-philipp.tomsich@vrull.eu>


On 11/8/22 12:55, Philipp Tomsich wrote:
> Consider creating a polarity-reversed mask from a set-bit (i.e., if
> the bit is set, produce all-ones; otherwise: all-zeros).  Using Zbb,
> this can be expressed as bexti, followed by an addi of minus-one.  To
> enable the combiner to discover this opportunity, we need to split the
> canonical expression for "(a & (1 << BIT_NO)) ? 0 : -1" into a form
> combinable into bexti.
>
> Consider the function:
>      long f(long a)
>      {
>        return (a & (1 << BIT_NO)) ? 0 : -1;
>      }
> This produces the following sequence prior to this change:
> 	andi	a0,a0,16
> 	seqz	a0,a0
> 	neg	a0,a0
> 	ret
> Following this change, it results in:
> 	bexti	a0,a0,4
> 	addi	a0,a0,-1
> 	ret
>
> gcc/ChangeLog:
>
> 	* config/riscv/bitmanip.md: Add a splitter to generate
>            polarity-reversed masks from a set bit using bexti + addi.
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.target/riscv/zbs-bexti.c: New test.

OK


Jeff



  reply	other threads:[~2022-11-17 14:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08 19:55 Philipp Tomsich
2022-11-17 14:43 ` Jeff Law [this message]
2022-11-17 15:25   ` 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=9b0f6fb5-a2e6-3064-5c77-f3357a0a3344@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).