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/111519] [13/14 Regression] Wrong code at -O3 on x86_64-linux-gnu since r13-455-g1fe04c497d
Date: Tue, 10 Oct 2023 07:56:15 +0000	[thread overview]
Message-ID: <bug-111519-4-3NxTS3M9Sk@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-111519-4@http.gcc.gnu.org/bugzilla/>

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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
  g = 0;
  for (; g <= 1; g++) {
    *n = **j;
    k[g] = 0 != &m;
    *e = l && k[0];
  }

this is

  g = 0;
  d = f; // 0
  k[0] = 1;
  f = 1;
  g = 1;
  d = f; // 1
  k[1] = 1;
  f = 1;
  g = 2;

that looks still equivalent to what we have after unrolling this loop in
cunroll
and also after DOM3 which really points to strlen wrongly considering 'd' zero.
Before strlen we have

  <bb 7> [local count: 1605787]:
  _2 = e;
  _3 = *_2;
  k[0] = 1;
  l.8_91 = l;
  if (l.8_91 != 0B)
    goto <bb 8>; [70.00%]
  else
    goto <bb 9>; [30.00%]

  <bb 8> [local count: 1124051]:

  <bb 9> [local count: 1605787]:
  # prephitmp_82 = PHI <0(7), 1(8)>
  *_2 = prephitmp_82;
  _7 = e;
  _8 = *_7;
  k[1] = 1;
  l.8_10 = l;
  if (l.8_10 != 0B)
    goto <bb 10>; [70.00%]
  else
    goto <bb 11>; [30.00%]

  <bb 10> [local count: 1124051]:

  <bb 11> [local count: 14598063]:
  # prephitmp_89 = PHI <1(10), 0(9)>
  *_7 = prephitmp_89;
  d = _8;
  g = 2;
  if (q_32(D) == 0)
    goto <bb 12>; [33.00%]
  else
    goto <bb 18>; [67.00%]

that's the OK part, now into the tail loop - q_32(D) is 1:

  <bb 18> [local count: 9780702]:
  o.16_80 = o;
  if (o.16_80 <= 3)
    goto <bb 13>; [89.00%]
  else
    goto <bb 17>; [11.00%]

  <bb 13> [local count: 8704825]:
  d_lsm0.28_35 = d;

  <bb 14> [local count: 79134774]:
  # prephitmp_6 = PHI <o.16_80(13), _85(14)>
  _96 = (int) d_lsm0.28_35;
  _85 = prephitmp_6 + 1;
  if (_85 != 4)
    goto <bb 14>; [89.00%]
  else
    goto <bb 16>; [11.00%]

  <bb 16> [local count: 8704825]:
  a = _96;
  o = 4;

  <bb 17> [local count: 14598063]:
  a.17_23 = a;
  printf ("%d\n", a.17_23);
  return 0;

and the strlen pass replaces d_lsm0.28_35 = d; with d_lsm0.28_35 = 0; which
is wrong.

Your assessment

"Here the assignment to *_73 overwrites the value of f (at *e) which then
invalidates the use of _72 resulting in the wrong value for d."

seems odd, it's exactly writing the correct value (in fact both stores
write the value one, only the very original value is zero).

I don't know the strlen pass at all so I can't tell where it goes wrong.

  parent reply	other threads:[~2023-10-10  7:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 13:20 [Bug tree-optimization/111519] New: " shaohua.li at inf dot ethz.ch
2023-09-21 15:35 ` [Bug tree-optimization/111519] " pinskia at gcc dot gnu.org
2023-09-21 15:47 ` pinskia at gcc dot gnu.org
2023-09-21 16:00 ` rguenth at gcc dot gnu.org
2023-10-09 22:05 ` roger at nextmovesoftware dot com
2023-10-10  7:56 ` rguenth at gcc dot gnu.org [this message]
2023-10-10  8:21 ` jakub at gcc dot gnu.org
2023-10-10  8:26 ` rguenth at gcc dot gnu.org
2023-10-10  8:31 ` rguenth at gcc dot gnu.org
2023-10-10  8:33 ` rguenth at gcc dot gnu.org
2023-10-10 10:37 ` rguenth at gcc dot gnu.org
2023-10-11  7:09 ` cvs-commit at gcc dot gnu.org
2023-10-11  7:23 ` cvs-commit at gcc dot gnu.org
2023-10-11  7:24 ` jakub at gcc dot gnu.org
2023-11-02  9:05 ` pinskia 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-111519-4-3NxTS3M9Sk@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).