public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "amacleod at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/100781] [12 Regression] Emitted binary code changes when -g is enabled at -O2
Date: Thu, 27 May 2021 18:13:57 +0000	[thread overview]
Message-ID: <bug-100781-4-ztXNchKZbw@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-100781-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #6 from Andrew Macleod <amacleod at redhat dot com> ---
So the new code base provides a more complete/consistent export list, and makes
use of imports now.  An import is the incoming value which can change an
outgoing value.
In this particular case we see:
<bb 3> :
  _2 = (long int) f$b_17;
 _3 = _2 <= e_12(D);
 h_13 = (int) _3;
 i_14 = (int) d_10(D);
 _5 = h_13 >= i_14;
 n_15 = (int) _5;
 if (h_13 < i_14)
   goto <bb 4>; [INV]
 else
   goto <bb 5>; [INV]

 <bb 4> :
 // predicted unlikely by goto predictor.
 // predicted unlikely by goto predictor.
 if (d_10(D) != 0)
   goto <bb 6>; [INV]
 else
   goto <bb 7>; [INV]

We look at more of these names than we use to, and f$b_17 is now taken into
account. bb3 has a back edge from bb9, so we do a little back edge tracking
earlier than we use to.
Long story short:  During the initial traversal, none of the other names in the
block have yet been fully fleshed out when we arrive back at bb3 from the
bottom, so the propagation engine uses global values as an initial value.
In particular, we use h_13 which has none, so defaults to VARYING. And in "if
h_13 < i_14", that gives us nothing for d_10.
however, we later process h_13 = (int)_3, and discover it is actually [0,1]
since _3 is a boolean.
We propagate this new [0,1] value, but since it isnt in the dependency chain
for d_10, we never re-evaluate d_10.

Previously, the first time we evaluate d_10 we see that the edge 3->4 requires  
[0,1] < i_14 to be true, which means i_14 = [1, +INF] which also means that
d_10 is non-zero and we fold the condition.

The next round of GORI code I'm about to check in makes it fair straightforward
to grab an initial value for h_13 even if it hasn't been fully evaluated yet..
so instead of VARYING, we'll get the [0,1] range for h_13, and everything will
return to the way it was.

There is more update/propagation/ordering stuff to come, but I suspect the
forthcoming changes will resolve most of these sorts of issues.

  parent reply	other threads:[~2021-05-27 18:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-26 21:12 [Bug tree-optimization/100781] New: " tlwang at uwaterloo dot ca
2021-05-26 21:30 ` [Bug tree-optimization/100781] [12 Regression] " pinskia at gcc dot gnu.org
2021-05-26 21:31 ` pinskia at gcc dot gnu.org
2021-05-26 21:33 ` pinskia at gcc dot gnu.org
2021-05-26 21:38 ` pinskia at gcc dot gnu.org
2021-05-27  6:20 ` aldyh at gcc dot gnu.org
2021-05-27 18:13 ` amacleod at redhat dot com [this message]
2021-06-01  1:32 ` cvs-commit at gcc dot gnu.org
2021-06-01  1:36 ` amacleod at redhat dot com
2021-06-01  1:36 ` amacleod at redhat dot com
2021-07-14 21:58 ` cvs-commit 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-100781-4-ztXNchKZbw@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).