On Mon, Jun 7, 2021 at 4:32 PM Andrew MacLeod <amacl...@redhat.com> wrote:
> Aldy, I think this means we can use global information in the get_global > query for ranger if "cfun->after_inlining" is true, otherwise do what we > currently do. Tested on x86-64 Linux. OK for trunk? Aldy
From 914810565183ad2cdac82ed5babd1f182346a728 Mon Sep 17 00:00:00 2001 From: Aldy Hernandez <al...@redhat.com> Date: Sun, 13 Jun 2021 16:20:33 +0200 Subject: [PATCH] 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. --- 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); -- 2.31.1