public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "uwe at netbsd dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/101469] wrong code with "-O2 -fPIE" for SH
Date: Sun, 18 Jul 2021 17:04:57 +0000	[thread overview]
Message-ID: <bug-101469-4-HHfZFCPMYM@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-101469-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #2 from Valeriy E. Ushakov <uwe at netbsd dot org> ---
I don't have the latest gcc handy, but I see this bug already in an old netbsd
tree from about an year ago with gcc 8.4.0

As hgutch@n.o pointed out, this seems to be a problem with this peephole2:

;;      mov     r12,r0
;;      add     #-48,r0     ->  add     #-48,r12
;;      mov.l   r0,@(4,r10)     mov.l   r12,@(4,r10)
;;      (r12 dead)
(define_peephole2
  [(set (match_operand:SI 0 "arith_reg_dest")
        (match_operand:SI 1 "arith_reg_dest"))
   (set (match_dup 0) (plus:SI (match_dup 0)
                               (match_operand:SI 2 "const_int_operand")))
   (set (match_operand:SI 3 "general_movdst_operand") (match_dup 0))]


as far as I can tell, it optimizes

  r0 = r2
  r0 += 64
  *(r0+4) = r0

to

  r2 += 64
  *(r0+4) = r2

failing to notice that the the destination uses r0 too.

Then in the cprop-registers step that r0 is replaced with r12 b/c of r0 = r12
done a bit earlier.

  parent reply	other threads:[~2021-07-18 17:04 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-16  9:48 [Bug c/101469] New: " rin at NetBSD dot org
2021-07-18  4:18 ` [Bug target/101469] " rin at NetBSD dot org
2021-07-18 17:04 ` uwe at netbsd dot org [this message]
2021-07-19  5:23 ` rin at NetBSD dot org
2021-07-19  5:55 ` olegendo at gcc dot gnu.org
2021-07-19  6:13 ` rin at NetBSD dot org
2021-07-21 16:40 ` rin at NetBSD dot org
2023-07-07 10:25 ` olegendo at gcc dot gnu.org
2023-07-07 10:28 ` olegendo at gcc dot gnu.org
2023-07-10  2:39 ` rin at NetBSD dot org
2023-07-10  2:45 ` olegendo at gcc dot gnu.org
2023-07-10  3:36 ` rin at NetBSD dot org
2023-07-14  1:40 ` cvs-commit at gcc dot gnu.org
2023-07-14  1:45 ` cvs-commit at gcc dot gnu.org
2023-07-14  1:51 ` cvs-commit at gcc dot gnu.org
2023-07-14  2:03 ` cvs-commit at gcc dot gnu.org
2023-07-14  2:10 ` olegendo at gcc dot gnu.org
2023-07-18  3:57 ` rin at NetBSD dot org
2023-07-18  4:05 ` olegendo 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-101469-4-HHfZFCPMYM@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).