public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "slyfox at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/100782] [11 Regression] sh4 ICEs on -O2 -fPIE -fstack-protector: internal compiler error: in curr_insn_transform, at lra-constraints.c:4132
Date: Mon, 09 Aug 2021 06:51:50 +0000	[thread overview]
Message-ID: <bug-100782-4-JIvPEZN957@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100782-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Sergei Trofimovich <slyfox at gcc dot gnu.org> ---
Trying to understand why rejection happens: -fdump-rtl-all-slim 295r.reload
says:

         Choosing alt 0 in insn 12:  (0) =r  (1) %0  (2) rI08
{*addsi3_compact_lra}
            alt=0: No input/output reload -- refuse
         ...
         12: r15:SI=r15:SI-0x4

I'm surprised the same (hard) reg is used in source and destination in insn 12.

*addsi3_compact_lra hints at special assumptions about it:

;; The *addsi3_compact is made an insn_and_split and accepts actually
;; impossible constraints to make LRA's register elimination work well on SH.
;; The problem is that LRA expects something like
;;    (set rA (plus rB (const_int N)))
;; to work.  We can do that, but we have to split out an additional reg-reg
;; copy or constant load before the actual add insn.
;; Use u constraint for that case to avoid the invalid value in the stack
;; pointer.
;; This also results in better code when LRA is not used.  However, we have
;; to use different sets of patterns and the order of these patterns is
;; important.
;; In some cases the constant zero might end up in operands[2] of the
;; patterns.  We have to accept that and convert it into a reg-reg move.
(define_insn_and_split "*addsi3_compact_lra"
  [(set (match_operand:SI 0 "arith_reg_dest" "=r,&u")
        (plus:SI (match_operand:SI 1 "arith_reg_operand" "%0,r")
                 (match_operand:SI 2 "arith_or_int_operand" "rI08,rn")))]
  "TARGET_SH1 && sh_lra_p ()
   && (! reg_overlap_mentioned_p (operands[0], operands[1])
       || arith_operand (operands[2], SImode))"
  "@
        add     %2,%0
        #"
  "&& reload_completed
   && ! reg_overlap_mentioned_p (operands[0], operands[1])"
  [(set (match_dup 0) (match_dup 2))
   (set (match_dup 0) (plus:SI (match_dup 0) (match_dup 1)))]
{
  /* Prefer 'mov r0,r1; add #imm8,r1' over 'mov #imm8,r1; add r0,r1'  */
  if (satisfies_constraint_I08 (operands[2]))
    std::swap (operands[1], operands[2]);
}
  [(set_attr "type" "arith")])

  parent reply	other threads:[~2021-08-09  6:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 21:38 [Bug target/100782] New: " slyfox at gcc dot gnu.org
2021-05-28 10:32 ` [Bug target/100782] " rguenth at gcc dot gnu.org
2021-06-21 22:25 ` slyfox at gcc dot gnu.org
2021-07-06  6:52 ` rguenth at gcc dot gnu.org
2021-07-06  7:34 ` slyfox at gcc dot gnu.org
2021-07-06 21:29 ` slyfox at gcc dot gnu.org
2021-07-28  7:07 ` rguenth at gcc dot gnu.org
2021-08-09  6:51 ` slyfox at gcc dot gnu.org [this message]
2022-04-21  7:49 ` rguenth at gcc dot gnu.org
2023-05-29 10:05 ` [Bug target/100782] [11 Regression] sh4 ICEs on -O2 -fPIE -fstack-protector: internal compiler error: in curr_insn_transform, at lra-constraints.c jakub 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-100782-4-JIvPEZN957@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).