]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Pick up global ranges in ranger after inlining.
authorAldy Hernandez <aldyh@redhat.com>
Sun, 13 Jun 2021 14:20:33 +0000 (16:20 +0200)
committerAldy Hernandez <aldyh@redhat.com>
Mon, 14 Jun 2021 06:19:21 +0000 (08:19 +0200)
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.

gcc/value-query.cc

index 9047e271b5b2000d4db338d5d047af99d90da0ef..93609f3c7c42ab6178da20d5a50790e465423e34 100644 (file)
@@ -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);