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 target/109092] [13 Regression] ICE: RTL check: expected code 'reg', have 'subreg' in rhs_regno, at rtl.h:1932 when building libgcc on riscv64
Date: Tue, 14 Mar 2023 18:30:37 +0000	[thread overview]
Message-ID: <bug-109092-4-HgTZXKB4r9@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109092-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #5 from Uroš Bizjak <ubizjak at gmail dot com> ---
(In reply to Uroš Bizjak from comment #2)
> (In reply to Andrew Pinski from comment #1)
> 
> > The issue is register_operand accepts subreg but then REGNO is checked on it.
> > That is obviously wrong. It should be "REG_P (operands[1]) && REGNO
> > (operands[1]) == VL_REGNUM" instead ...
> 
> reg_or_subregno is better.

However, please note that reg_or_subregno asserts that we always have SUBREG of
REG:

unsigned int
reg_or_subregno (const_rtx reg)
{
  if (GET_CODE (reg) == SUBREG)
    reg = SUBREG_REG (reg);
  gcc_assert (REG_P (reg));
  return REGNO (reg);
}

but before reload register_operand allows SUBREG of MEM:

bool
register_operand (rtx op, machine_mode mode)
{
  if (GET_CODE (op) == SUBREG)
    {
      rtx sub = SUBREG_REG (op);

      /* Before reload, we can allow (SUBREG (MEM...)) as a register operand
         because it is guaranteed to be reloaded into one.
         Just make sure the MEM is valid in itself.
         (Ideally, (SUBREG (MEM)...) should not exist after reload,
         but currently it does result from (SUBREG (REG)...) where the
         reg went on the stack.)  */
      if (!REG_P (sub) && (reload_completed || !MEM_P (sub)))
        return false;
    }
  else if (!REG_P (op))
    return false;
  return general_operand (op, mode);
}

OTOH, we do have:

rtlanal.h:const unsigned int MEM_REGNO = ~0U;

which implies that it is possible to get a REGNO of a MEM, so perhaps the
assert in reg_or_subregno is too strict.

  parent reply	other threads:[~2023-03-14 18:30 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-10 17:32 [Bug rtl-optimization/109092] New: " zsojka at seznam dot cz
2023-03-10 17:37 ` [Bug target/109092] " pinskia at gcc dot gnu.org
2023-03-13  8:52 ` rguenth at gcc dot gnu.org
2023-03-13 10:03 ` ubizjak at gmail dot com
2023-03-13 17:01 ` jakub at gcc dot gnu.org
2023-03-14 18:12 ` law at gcc dot gnu.org
2023-03-14 18:30 ` ubizjak at gmail dot com [this message]
2023-03-15  1:53 ` juzhe.zhong at rivai dot ai
2023-03-17  9:50 ` cvs-commit at gcc dot gnu.org
2023-03-27  7:44 ` pinskia at gcc dot gnu.org
2024-01-22 12:55 ` 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-109092-4-HgTZXKB4r9@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).