public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1417] Pick up global ranges in ranger after inlining.
@ 2021-06-14  6:19 Aldy Hernandez
  0 siblings, 0 replies; only message in thread
From: Aldy Hernandez @ 2021-06-14  6:19 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:5a897a6b1b3e11677fcac3212d14e61d65e893ea

commit r12-1417-g5a897a6b1b3e11677fcac3212d14e61d65e893ea
Author: Aldy Hernandez <aldyh@redhat.com>
Date:   Sun Jun 13 16:20:33 2021 +0200

    Pick up global ranges in ranger after inlining.
    
    Ranger was not picking up global ranges because doing so could remove
    __builtin_unreachable calls too early to the detriment of LTO.  However,
    we can safely remove these calls after inlining.  This patch removes the
    restriction and allows ranger to pick up global ranges under these
    circumstances.
    
    Tested on x86-64 Linux.
    
    gcc/ChangeLog:
    
            * value-query.cc (gimple_range_global): Call get_range_global
            if called after inlining.

Diff:
---
 gcc/value-query.cc | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/gcc/value-query.cc b/gcc/value-query.cc
index 9047e271b5b..93609f3c7c4 100644
--- a/gcc/value-query.cc
+++ b/gcc/value-query.cc
@@ -397,14 +397,20 @@ get_range_global (irange &r, tree name)
     r.set_varying (type);
 }
 
-// ?? Like above, but only for default definitions of NAME.  This is
-// so VRP passes using ranger do not start with known ranges,
-// otherwise we'd eliminate builtin_unreachables too early because of
-// inlining.
+// This is where the ranger picks up global info to seed initial
+// requests.  It is a slightly restricted version of
+// get_range_global() above.
+//
+// The reason for the difference is that we can always pick the
+// default definition of an SSA with no adverse effects, but for other
+// SSAs, if we pick things up to early, we may prematurely eliminate
+// builtin_unreachables.
 //
 // Without this restriction, the test in g++.dg/tree-ssa/pr61034.C has
-// all of its unreachable calls removed too early.  We should
-// investigate whether we should just adjust the test above.
+// all of its unreachable calls removed too early.
+//
+// See discussion here:
+// https://gcc.gnu.org/pipermail/gcc-patches/2021-June/571709.html
 
 value_range
 gimple_range_global (tree name)
@@ -412,7 +418,7 @@ gimple_range_global (tree name)
   gcc_checking_assert (gimple_range_ssa_p (name));
   tree type = TREE_TYPE (name);
 
-  if (SSA_NAME_IS_DEFAULT_DEF (name))
+  if (SSA_NAME_IS_DEFAULT_DEF (name) || (cfun && cfun->after_inlining))
     {
       value_range vr;
       get_range_global (vr, name);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-14  6:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14  6:19 [gcc r12-1417] Pick up global ranges in ranger after inlining Aldy Hernandez

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).