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/107972] backward propagation of finite property not performed
Date: Wed, 07 Dec 2022 15:31:52 +0000	[thread overview]
Message-ID: <bug-107972-4-nHcmhuf7AG@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-107972-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Andrew Macleod <amacleod at redhat dot com> ---
Its because we don't go back and re-propagate into previous basic block.  Take
an integral vexample:

unsigned 
foo (unsigned a, unsigned b)
{
  unsigned res = a + b;
  if (res > 100)
    return 42
  if (a > 30 || b > 30)
    __builtin_unreachable ();
  if (res > 100)
    return 42
  return res;

The branch which restricts the range of a and b to [0,30] causes GORI to
recompute "res = a + b" on each edge, so those values are pushed along any
outgoing edges, and when we see res > 100 the second time we fold that away.

Thats all handled buy GORI which is basic-block oriented only.  At no point
(yet anyway) do we attempt to push these values back further in the CFG, so
therefore we don't touch the conditions that were encountered earlier, and
cannot eliminate the earlier compare and return.  

I have contemplated a new kind of VRP analysis pass which leverages what we did
with 'assume', propagates known values backwards and looks for opportunities
earlier in the CFG that are exposed by information determined later in the IL. 
 This sort of thing would probably require such a pass.

  parent reply	other threads:[~2022-12-07 15:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-05 13:35 [Bug tree-optimization/107972] New: " drepper.fsp+rhbz at gmail dot com
2022-12-05 13:43 ` [Bug tree-optimization/107972] " jakub at gcc dot gnu.org
2022-12-06  9:27 ` cvs-commit at gcc dot gnu.org
2022-12-06  9:57 ` jakub at gcc dot gnu.org
2022-12-07 15:31 ` amacleod at redhat dot com [this message]
2023-02-14 21:28 ` 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-107972-4-nHcmhuf7AG@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).