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: Vineet Gupta <vineetg@rivosinc.com>,
	Jeff Law <jlaw@ventanamicro.com>,
	Christoph Muellner <christoph.muellner@vrull.eu>,
	Palmer Dabbelt <palmer@rivosinc.com>,
	Kito Cheng <kito.cheng@gmail.com>
Subject: Re: [PATCH] RISC-V: Use bseti to cover more immediates than with ori alone
Date: Tue, 15 Nov 2022 20:43:19 -0700	[thread overview]
Message-ID: <9f2ad85c-e362-7f3d-5213-c61e61d64866@gmail.com> (raw)
In-Reply-To: <20221110213445.3592438-1-philipp.tomsich@vrull.eu>


On 11/10/22 14:34, Philipp Tomsich wrote:
> Sequences of the form "a | C" with C being the positive half of a
> signed immediate's range with one extra bit set in addtion are mapped
> to ori and one binvi to avoid using a temporary (and a multi-insn
> sequence to load C into that temporary).
>
> gcc/ChangeLog:
>
> 	* config/riscv/bitmanip.md (*bseti<mode>_extrabit): New pattern
>
> gcc/testsuite/ChangeLog:
>
> 	* gcc.target/riscv/zbs-bseti.c: New test.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@vrull.eu>
> ---
> - Depends on a predicate posted in "RISC-V: Optimize branches testing
>    a bit-range or a shifted immediate".  Depending on the order of
>    applying these, I'll take care to pull that part out of the other
>    patch if needed.
>
>   gcc/config/riscv/bitmanip.md               | 19 +++++++++++++++
>   gcc/testsuite/gcc.target/riscv/zbs-bseti.c | 27 ++++++++++++++++++++++
>   2 files changed, 46 insertions(+)
>   create mode 100644 gcc/testsuite/gcc.target/riscv/zbs-bseti.c
>
> diff --git a/gcc/config/riscv/bitmanip.md b/gcc/config/riscv/bitmanip.md
> index 06126ac4819..436ff4ba958 100644
> --- a/gcc/config/riscv/bitmanip.md
> +++ b/gcc/config/riscv/bitmani
> @@ -512,6 +512,25 @@
>     "bseti\t%0,%1,%S2"
>     [(set_attr "type" "bitmanip")])
>   
> +; Catch those cases where we can use a bseti + ori or bseti + bseti
> +; instead of a lui + addi + or sequence.
> +(define_insn_and_split "*bseti<mode>_extrabit"
> +  [(set (match_operand:X 0 "register_operand" "=r")
> +	(ior:X (match_operand:X 1 "register_operand" "r")
> +	       (match_operand:X 2 "uimm_extra_bit_operand" "i")))]
> +  "TARGET_ZBS"
> +  "#"
> +  "&& reload_completed"
> +  [(set (match_dup 0) (ior:X (match_dup 1) (match_dup 3)))
> +   (set (match_dup 0) (ior:X (match_dup 0) (match_dup 4)))]
> +{
> +	unsigned HOST_WIDE_INT bits = UINTVAL (operands[2]);
> +	unsigned HOST_WIDE_INT topbit = HOST_WIDE_INT_1U << floor_log2 (bits);
> +
> +	operands[3] = GEN_INT (bits &~ topbit);
> +	operands[4] = GEN_INT (topbit);
> +})

I briefly thought you might need an earlyclobber for the output, but you 
consume the input register in the first generated insn, so you should be OK.


OK.

jeff



      reply	other threads:[~2022-11-16  3:43 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-10 21:34 Philipp Tomsich
2022-11-16  3:43 ` Jeff Law [this message]

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=9f2ad85c-e362-7f3d-5213-c61e61d64866@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).