A lot of time was being spent processing inferred ranges during a cache
update. Requesting the range of an argument during processing of
inferred ranges was suppose to be cheap because they have already been
calculated during folding, and so should just be available. The problem
demonstrated here is GORI determined the SSA_NAMES being queried were
invariant, and therefore the cache normally didnt do any lookups or
calculations.
The inferred range processing was calling entry_range, which didn't have
a check for invariance. That check usually happened earlier in the
lookup process, and it was therefore doing a full dom lookup and range
calculation.
This patch simply adds the check to entry_range to check for invariance,
and if so, use the definition value rather than doing a cache fill, as
is done in other places.
This drops the compile time of VRP in the testcase from:
tree VRP : 23.84 ( 13%) 43M ( 4%)
tree Early VRP : 11.18 ( 6%) 12M ( 1%)
TOTAL : 181.97 1175M
to
tree VRP : 8.22 ( 5%) 43M ( 4%)
tree Early VRP : 3.68 ( 2%) 12M ( 1%)
TOTAL : 159.04 1175M
Overall compile time spent in VRP of GCC source files improved by about
0.7%.
Bootstraps on build-x86_64-pc-linux-gnu with no regressions. OK?
Andrew
From 97bea858ff782dc5c80490bb48cbd3241ad3413c Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacl...@redhat.com>
Date: Mon, 25 Nov 2024 09:50:33 -0500
Subject: [PATCH 1/3] Do not calculate an entry range for invariant names.
If an SSA_NAME is invariant, do not calculate an on_entry value.
PR tree-optimization/117467
* gimple-range-cache.cc (ranger_cache::entry_range): Do not
invoke range_from_dom for invariant ssa-names.
---
gcc/gimple-range-cache.cc | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/gcc/gimple-range-cache.cc b/gcc/gimple-range-cache.cc
index 1788a935429..3935e0b8dfd 100644
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1184,6 +1184,13 @@ ranger_cache::entry_range (vrange &r, tree name, basic_block bb,
return;
}
+ // If NAME is invariant, simply return the defining range.
+ if (!gori ().has_edge_range_p (name))
+ {
+ range_of_def (r, name);
+ return;
+ }
+
// Look for the on-entry value of name in BB from the cache.
// Otherwise pick up the best available global value.
if (!m_on_entry.get_bb_range (r, name, bb))
--
2.45.0