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/102650] Dead Code Elimination Regression at -O3 (trunk vs 11.2.0)
Date: Fri, 08 Oct 2021 16:45:04 +0000	[thread overview]
Message-ID: <bug-102650-4-Lh0vGBywP6@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-102650-4@http.gcc.gnu.org/bugzilla/>

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

Andrew Macleod <amacleod at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |amacleod at redhat dot com

--- Comment #1 from Andrew Macleod <amacleod at redhat dot com> ---
This is a result of the vagaries of the single subrange value-range.

VRP is seeing:
# f_11 = PHI <-1(2), 2(3)>
  goto <bb 6>; [100.00%]

  <bb 5> [local count: 955630225]:
  _3 = (unsigned short) f_11;
  _6 = _3 + 2;
  e_19 = (short int) _6;

It knows f_11 is [-1, 2] and when that is cast to a ushort,  produces ~[3,
65534].

That is all we knew about it in GCC11, so when we calculate_6 = ~[3,65534] + 2 
it comes up with [1,4] and the e_19 == 0 later on then can be folded away.

in gcc12, EVRP has figured out that _3 is unsigned short [2, 2][+INF, +INF]. 
which if we add 2 to it, would come up with [1,1][4,4] which would be perfect.

We save this to the value_range global table in EVRP, but alas it gets
transliterated to a single pair value_range : _3  : unsigned short [2, +INF]

Now when VRP calculates ~[3, 65534] and intersects that with the known global
[2, +INF] the legacy intersect routine  has to come up with  pair and decides
to keep [2, +INF].  
when you add 2 to that, 0 is no longer eliminated.

  reply	other threads:[~2021-10-08 16:45 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-08 13:47 [Bug tree-optimization/102650] New: " theodort at inf dot ethz.ch
2021-10-08 16:45 ` amacleod at redhat dot com [this message]
2021-10-11  8:34 ` [Bug tree-optimization/102650] [12 Regression] " rguenth at gcc dot gnu.org
2021-11-05 20:20 ` amacleod at redhat dot com
2022-01-19 14:13 ` rguenth at gcc dot gnu.org
2022-01-19 14:18 ` rguenth at gcc dot gnu.org
2022-01-19 15:15 ` amacleod at redhat dot com
2022-01-20  9:20 ` rguenth at gcc dot gnu.org
2022-01-20 14:52 ` amacleod at redhat dot com
2022-03-23  8:45 ` rguenth at gcc dot gnu.org
2022-11-03 19:33 ` [Bug tree-optimization/102650] [12/13 " amacleod at redhat dot com

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-102650-4-Lh0vGBywP6@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).