public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/109138] [10/11/12/13 Regression] wrong code at -O1 and above on x86_64-linux-gnu
Date: Wed, 15 Mar 2023 09:39:59 +0000	[thread overview]
Message-ID: <bug-109138-4-LDxAqS2yZ3@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109138-4@http.gcc.gnu.org/bugzilla/>

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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I don't think this has anything to do with reassoc though.
The testcase looks incorrect to me.
Because d is defined in the scope of the outer loop's body, for b == 0 a is -1U
and
so the inner loop does nothing, d is set to 1, a is set to 0 and then d goes
out of scope.
Then for b = 1, a scope with d variable is entered but the variable is again
uninitialized, a <= 0 is true, and we use the uninitialized variable.
fixup_cfg1 dump shows this nicely with the clobber in there:

  <bb 2> :
  b = 0;
  goto <bb 6>; [INV]

  <bb 3> :
  d.0_1 = d;
  if (d.0_1 != 0)
    goto <bb 5>; [INV]
  else
    goto <bb 4>; [INV]

  <bb 4> :
L:
  a.1_2 = a;
  if (a.1_2 == 0)
    goto <bb 3>; [INV]
  else
    goto <bb 5>; [INV]

  <bb 5> :
  d = 1;
  a.2_3 = a;
  _4 = a.2_3 + 1;
  a = _4;
  d = {CLOBBER(eol)};
  b = b + 1;

  <bb 6> :
  if (b <= 1)
    goto <bb 4>; [INV]
  else
    goto <bb 7>; [INV]

  <bb 7> :
  D.2753 = 0;
  return D.2753;

  parent reply	other threads:[~2023-03-15  9:40 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-15  5:20 [Bug tree-optimization/109138] New: " zhendong.su at inf dot ethz.ch
2023-03-15  6:07 ` [Bug tree-optimization/109138] " pinskia at gcc dot gnu.org
2023-03-15  8:40 ` rguenth at gcc dot gnu.org
2023-03-15  8:51 ` pinskia at gcc dot gnu.org
2023-03-15  9:26 ` [Bug tree-optimization/109138] [10/11/12/13 Regression] " jakub at gcc dot gnu.org
2023-03-15  9:39 ` jakub at gcc dot gnu.org [this message]
2023-03-15 10:54 ` zhendong.su at inf dot ethz.ch

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-109138-4-LDxAqS2yZ3@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).