public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <jeffreyalaw@gmail.com>
To: Hans-Peter Nilsson <hp@axis.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH] reload: Handle generating reloads that also clobbers flags
Date: Sat, 29 Apr 2023 12:03:17 -0600	[thread overview]
Message-ID: <8af8ca8b-858d-1d54-295c-fc050bed9062@gmail.com> (raw)
In-Reply-To: <20230418141217.CF9FF203FA@pchp3.se.axis.com>



On 4/18/23 08:12, Hans-Peter Nilsson wrote:
>> Date: Tue, 18 Apr 2023 07:43:41 -0600
>> From: Jeff Law <jeffreyalaw@gmail.com>
> 
>> On 2/15/23 08:34, Hans-Peter Nilsson via Gcc-patches wrote:
>>> Regtested cris-elf with its LEGITIMIZE_RELOAD_ADDRESS
>>> disabled, where it regresses gcc.target/cris/rld-legit1.c;
>>> as expected, because that test guards proper function of its
>>> LEGITIMIZE_RELOAD_ADDRESS i.e., that there's no sign of
>>> decomposed address elements.
>>>
>>> LRA also causes a similar decomposition (and worse, in even
>>> smaller bits), but it can create valid insns as-is.
>>> Unfortunately, it doesn't have something equivalent to
>>> LEGITIMIZE_RELOAD_ADDRESS so it generates worse code for
>>> cases where that hook helped reload.
>>>
>>> I fear reload-related patches these days are treated like a
>>> redheaded stepchild and even worse as this one is intended
>>> for stage 1.  Either way, I need to create a reference to
>>> it, and it's properly tested and has been a help when
>>> working towards LRA, thus might help other targets: ok to
>>> install for the next stage 1?
>>>
>>> -- >8 --
>>> When LEGITIMIZE_RELOAD_ADDRESS for cris-elf is disabled,
>>> this code is now required for reload to generate valid insns
>>> from some reload-decomposed addresses, for example the
>>> (plus:SI
>>>    (sign_extend:SI (mem:HI (reg/v/f:SI 32 [ a ]) [1 *a_6(D)+0 S2 A8]))
>>>    (reg/v/f:SI 33 [ y ]))
>>> generated in gcc.target/cris/rld-legit1.c (a valid address
>>> but with two registers needing reload).  Now after decc0:ing,
>>> most SET insns for former cc0 targets need to be a parallel
>>> with a clobber of the flags register.  Such targets
>>> typically have TARGET_FLAGS_REGNUM set to a valid register.
>>>
>>> 	* reload1.cc (emit_insn_if_valid_for_reload_1): Rename from
>>> 	emit_insn_if_valid_for_reload.
>>> 	(emit_insn_if_valid_for_reload): Call new helper, and if a SET fails
>>> 	to be recognized, also try emitting a parallel that clobbers
>>> 	TARGET_FLAGS_REGNUM, as applicable.
>> BUt isn't it the case that we're not supposed to be exposing the flags
>> register until after reload?   And if that's the case, then why would
>> this be necessary?  Clearly I must be missing something.
> 
> That "supposed to" is only *one* possible implementation.
> The one in CRIS - and I believe the preferred one; one I
> should advocate more - is to *always* expose clobbering of
> the flags.  (I managed to do the CRIS decc0ification
> transformation without loss of performance.  There were much
> fewer issues with code taking PATTERN (insn) and failing on
> it being PARALLEL than I had expected, much thanks to use of
> rtx_single_set.)
> 
> Think about it: why should the semantics of a valid insn
> change after a "random" pass?  That's almost as crazy as the
> implied semantics of cc0.
Ah, yes, thanks for the reminder that there's multiple approaches here. 
If I cared enough it'd probably make more sense at this point to expose 
cc0 early on the H8 as doing so would allow easier codegen for overflow 
tests which in turn could significantly speed up the testsuite.

OK for the trunk.

jeff

      parent reply	other threads:[~2023-04-29 18:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-15 15:34 Hans-Peter Nilsson
2023-04-18 13:43 ` Jeff Law
2023-04-18 14:12   ` Hans-Peter Nilsson
2023-04-18 16:07     ` Eric Botcazou
2023-04-29 18:03     ` 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=8af8ca8b-858d-1d54-295c-fc050bed9062@gmail.com \
    --to=jeffreyalaw@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hp@axis.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).