From: Aldy Hernandez Date: Sun, 13 Jun 2021 14:20:33 +0000 (+0200) Subject: Pick up global ranges in ranger after inlining. X-Git-Tag: basepoints/gcc-13~6896 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5a897a6b1b3e11677fcac3212d14e61d65e893ea;p=thirdparty%2Fgcc.git 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 --git a/gcc/value-query.cc b/gcc/value-query.cc index 9047e271b5b2..93609f3c7c42 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);