public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "ubizjak at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/114810] [14 Regression] internal compiler error: in lra_split_hard_reg_for, at lra-assigns.cc:1868  (unable to find a register to spill) {*andndi3_doubleword_bmi} with -m32 -mstackrealign -O2 -mbmi -fno-exceptions -fno-plt
Date: Tue, 23 Apr 2024 06:02:36 +0000	[thread overview]
Message-ID: <bug-114810-4-xBzhjVhSSs@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-114810-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114810

--- Comment #12 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Vladimir Makarov from comment #9)
> (In reply to Uroš Bizjak from comment #7)
> >
> > 
> > Please note that the insn is defined as:
> > 
> > (define_insn_and_split "*andn<dwi>3_doubleword_bmi"
> >   [(set (match_operand:<DWI> 0 "register_operand" "=&r,r,r")
> > 	(and:<DWI>
> > 	  (not:<DWI> (match_operand:<DWI> 1 "register_operand" "r,0,r"))
> > 	  (match_operand:<DWI> 2 "nonimmediate_operand" "ro,ro,0")))
> >    (clobber (reg:CC FLAGS_REG))]
> > 
> > where the problematic alternative (=&r,r,ro) allows a memory input in its
> > operand 2 constraint. The allocator could spill a DImode value to a stack in
> > advance and reload the value from the memory in this particular alternative.
> 
> That is not how LRA (and the old reload) works.  If an operand matches the
> constraint (r in ro), it does not change its location (do reloads).
> 
> In general, it is possible to implement reloads for operands already matched
> to a constraint but this would significantly complicate already too
> complicated code.  And probably heuristics based on reload costs would
> reject such reloads anyway.
> 
> I probably could implement reg starvation recognition in process_alt_operand
> and penalize the alternative and most probably it will not affect other
> targets.  Still it is not easy because of different possible class subsets
> or intersections.
> 
> Still I think Jakub's solution is reasonable at this stage.  If I implement
> my proposed solution we could commit it after the release.

Yes, I agree. Not knowing the internals of the RA, it looked "obvious" that RA
could use memory operand here, and using this solution in the
target-independent code could solve the issue also for other register starved
targets.

Another long-term improvement in the RA could be allocating multi-regs in a
random order. As far as x86 is concerned, apart from passing function
parameters in registers and perhaps some asm constraint ("A"), there is no need
for double-word registers to be allocated in any specific order. The
double-word value could be allocated in {hi,lo} register tuplet, where hi and
lo can be any register. Using this approach, the RA could allocate a
double-word value also in [01]2[34]5 situation.

  parent reply	other threads:[~2024-04-23  6:02 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-22 17:57 [Bug target/114810] New: " kocelfc at tutanota dot com
2024-04-22 17:58 ` [Bug target/114810] " kocelfc at tutanota dot com
2024-04-22 18:22 ` jakub at gcc dot gnu.org
2024-04-22 19:10 ` ubizjak at gmail dot com
2024-04-22 19:23 ` ubizjak at gmail dot com
2024-04-22 19:31 ` [Bug rtl-optimization/114810] " ubizjak at gmail dot com
2024-04-22 19:45 ` vmakarov at gcc dot gnu.org
2024-04-22 20:07 ` ubizjak at gmail dot com
2024-04-22 21:36 ` jakub at gcc dot gnu.org
2024-04-22 21:48 ` vmakarov at gcc dot gnu.org
2024-04-22 21:56 ` jakub at gcc dot gnu.org
2024-04-23  5:53 ` ubizjak at gmail dot com
2024-04-23  6:02 ` ubizjak at gmail dot com [this message]
2024-04-23 12:29 ` jakub at gcc dot gnu.org
2024-04-23 12:46 ` ubizjak at gmail dot com
2024-04-23 21:31 ` cvs-commit at gcc dot gnu.org
2024-04-23 21:31 ` jakub at gcc dot gnu.org
2024-05-08 16:39 ` cvs-commit at gcc dot gnu.org

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=bug-114810-4-xBzhjVhSSs@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).