public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/102446] [9/10/11/12 Regression] wrong code at -O3 on x86_64-linux-gnu
Date: Wed, 22 Sep 2021 10:56:26 +0000	[thread overview]
Message-ID: <bug-102446-4-JMTzzXmVwC@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102446-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
void m() {
  int aa = 0, i = 0;
  for (; i < 3; i++)
    if (k < 0)
      aa |= *j;

Dump of assembler code for function m:
   0x0000000000400540 <+0>:     mov    0x200b16(%rip),%edi        # 0x60105c
<k>
   0x0000000000400546 <+6>:     mov    0x200b13(%rip),%rax        # 0x601060
<j>
   0x000000000040054d <+13>:    sar    $0x1f,%edi
=> 0x0000000000400550 <+16>:    and    (%rax),%edi
   0x0000000000400552 <+18>:    cmpw   $0x0,0x200af6(%rip)        # 0x601050
<d>

so we're loading *j before checking k < 0.  On GIMPLE that's OK:

  <bb 2> [local count: 268435456]:
  k.5_1 = k;
  j.6_2 = j;
  if (k.5_1 < 0)
    goto <bb 3>; [41.00%]
  else
    goto <bb 4>; [59.00%]

  <bb 3> [local count: 110058537]:
  j.6__lsm0.31_28 = *j.6_2;

  <bb 4> [local count: 268435456]:
  # aa_9 = PHI <j.6__lsm0.31_28(3), 0(2)>

but RTL if-conversion makes the load unconditional.

(insn 13 12 35 3 (set (reg/v:SI 89 [ j.6__lsm0.31 ])
        (mem:SI (reg/f:DI 83 [ j.6_2 ]) [1 *j.6_2+0 S4 A32])) 77
{*movsi_internal}
     (expr_list:REG_DEAD (reg/f:DI 83 [ j.6_2 ])
        (nil)))

I don't see any flags marking it as not trapping?

  parent reply	other threads:[~2021-09-22 10:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-22  9:00 [Bug tree-optimization/102446] New: " zhendong.su at inf dot ethz.ch
2021-09-22 10:50 ` [Bug tree-optimization/102446] " rguenth at gcc dot gnu.org
2021-09-22 10:54 ` [Bug tree-optimization/102446] [9/10/11/12 Regression] " jakub at gcc dot gnu.org
2021-09-22 10:56   ` Jan Hubicka
2021-09-22 10:56 ` rguenth at gcc dot gnu.org [this message]
2021-09-22 10:56 ` hubicka at ucw dot cz
2021-09-22 10:57 ` [Bug rtl-optimization/102446] " rguenth at gcc dot gnu.org
2021-09-22 10:57 ` rguenth at gcc dot gnu.org
2021-09-22 11:01 ` jakub at gcc dot gnu.org
2021-09-22 11:02 ` jakub at gcc dot gnu.org
2021-09-22 11:11 ` pinskia at gcc dot gnu.org
2021-09-22 11:29 ` jakub at gcc dot gnu.org
2022-01-30  2:04 ` pinskia at gcc dot gnu.org
2022-01-30 12:34 ` jakub at gcc dot gnu.org
2022-01-30 20:48 ` pinskia at gcc dot gnu.org
2022-05-27  9:46 ` [Bug rtl-optimization/102446] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-28 10:46 ` jakub at gcc dot gnu.org
2022-07-29 12:22 ` [Bug rtl-optimization/102446] [10/11 " rguenth at gcc dot gnu.org
2022-07-29 12:44 ` jakub at gcc dot gnu.org
2022-07-29 12:45 ` jakub at gcc dot gnu.org
2023-07-07 10:41 ` [Bug rtl-optimization/102446] [11 " rguenth 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-102446-4-JMTzzXmVwC@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).