From: Jeff Law <jeffreyalaw@gmail.com>
To: Robin Dapp <rdapp.gcc@gmail.com>,
Vineet Gupta <vineetg@rivosinc.com>,
gcc-patches@gcc.gnu.org
Cc: gnu-toolchain@rivosinc.com
Subject: Re: [RFC] RISC-V: elide sign extend when expanding cmp_and_jump
Date: Wed, 25 Oct 2023 07:32:35 -0600 [thread overview]
Message-ID: <33283a26-0271-41c3-8934-159658eab352@gmail.com> (raw)
In-Reply-To: <7fe582bc-d259-4d2a-bedf-4e1a334d7fc3@gmail.com>
On 10/25/23 01:12, Robin Dapp wrote:
> Hi Vineet,
>
> I was thinking of two things while skimming the code:
>
> - Couldn't we do this in the expanders directly? Or is the
> subreg-promoted info gone until we reach that?
Well, it doesn't seem like there's a lot of difference between doing it
in the generic expander bits vs target expander bits -- the former just
calls into the latter for the most part. Thus if the subreg-promoted
state is available in the target expander, I'd expect it to be available
in the generic expander.
It may be the case that we have more places to fix because we have
different expander paths (think conditional branches, conditional moves,
sCC and probably others). By catching it in riscv_expand_comparands he
caught a nice little choke point. I think what Vineet has done will
also work for RTL if-conversion.
>
> - Should some common-code part be more suited to handle that?
> We already elide redundant sign-zero extensions for other
> reasons. Maybe we could add subreg promoted handling there?
Unsure. I wouldn't be surprised if we were able to find similar code in
simplify-rtx or something like that. It's probably worth a quick looksie.
I also wonder if Vineet's work would subsume this local change. I've
been meaning to find testcases for this and determine if we should drop
it or clean it up and submit it upstream:
> +(define_insn "*branch<mode>_equals_zero"
> + [(set (pc)
> + (if_then_else
> + (match_operator 1 "equality_operator"
> + [(match_operand:ANYI 2 "register_operand" "r")
> + (const_int 0)])
> + (label_ref (match_operand 0 "" ""))
> + (pc)))]
> + "!partial_subreg_p (operands[2])"
> + "b%C1\t%2,zero,%0"
> + [(set_attr "type" "branch")
> + (set_attr "mode" "none")])
My sense is it's just papering over a missed simplification elsewhere.
Jeff
next prev parent reply other threads:[~2023-10-25 13:32 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-25 5:01 Vineet Gupta
2023-10-25 7:12 ` Robin Dapp
2023-10-25 13:32 ` Jeff Law [this message]
2023-10-25 13:47 ` Robin Dapp
2023-10-25 13:52 ` Jeff Law
2023-10-25 16:37 ` Vineet Gupta
2023-10-25 16:25 ` Vineet Gupta
2023-10-25 16:30 ` Jeff Law
2023-10-25 16:31 ` Vineet Gupta
2023-10-25 23:28 ` Vineet Gupta
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=33283a26-0271-41c3-8934-159658eab352@gmail.com \
--to=jeffreyalaw@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=gnu-toolchain@rivosinc.com \
--cc=rdapp.gcc@gmail.com \
--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).