On 6/25/24 00:27, Andrew Pinski wrote:
On Mon, Jun 24, 2024 at 7:35 PM Andrew Pinski <pins...@gmail.com> wrote:
This should be:
warning (OPT_Wdisabled_optimization, "Using fast VRP algorithm. %d basic blocks"
" exceeds %<%--param=vrp-block-limit=d%> limit",
n_basic_blocks_for_fn (fun), param_vrp_block_limit);
I had thought it was mentioned that options should be quoted but it is
not mentioned in the coding conventions:
https://gcc.gnu.org/codingconventions.html#Diagnostics
But it is mentioned in
https://inbox.sourceware.org/gcc/2d2bd844-2de4-ecff-7a07-b22350750...@gmail.com/
; This is why you were getting an error as you mentioned on IRC.
Note I filed https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115627 to
add it to the coding conventions. I might take a stab at adding the
rules mentioned in
https://inbox.sourceware.org/gcc-patches/8ac62fe2-e4bf-0922-4947-fca9567a0...@gmail.com/
since those are the ones which are detected right now.
Thanks,
Andrew
Thanks. Final version checked in:
Andrew
From 1ea95cc5e099d554764b82df8e972129e9d20885 Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacl...@redhat.com>
Date: Mon, 17 Jun 2024 11:38:46 -0400
Subject: [PATCH] Add param for bb limit to invoke fast_vrp.
If the basic block count is too high, simply use fast_vrp for all
VRP passes.
* doc/invoke.texi (vrp-block-limit): Document.
* params.opt (param=vrp-block-limit): New.
* tree-vrp.cc (fvrp_folder::execute): Invoke fast_vrp if block
count exceeds limit.
---
gcc/doc/invoke.texi | 3 +++
gcc/params.opt | 4 ++++
gcc/tree-vrp.cc | 14 ++++++++++++--
3 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index 23d90db2925..729dbc1691e 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -16849,6 +16849,9 @@ this parameter. The default value of this parameter is 50.
@item vect-induction-float
Enable loop vectorization of floating point inductions.
+@item vrp-block-limit
+Maximum number of basic blocks before VRP switches to a lower memory algorithm.
+
@item vrp-sparse-threshold
Maximum number of basic blocks before VRP uses a sparse bitmap cache.
diff --git a/gcc/params.opt b/gcc/params.opt
index d34ef545bf0..c17ba17b91b 100644
--- a/gcc/params.opt
+++ b/gcc/params.opt
@@ -1198,6 +1198,10 @@ The maximum factor which the loop vectorizer applies to the cost of statements i
Common Joined UInteger Var(param_vect_induction_float) Init(1) IntegerRange(0, 1) Param Optimization
Enable loop vectorization of floating point inductions.
+-param=vrp-block-limit=
+Common Joined UInteger Var(param_vrp_block_limit) Init(150000) Optimization Param
+Maximum number of basic blocks before VRP switches to a fast model with less memory requirements.
+
-param=vrp-sparse-threshold=
Common Joined UInteger Var(param_vrp_sparse_threshold) Init(3000) Optimization Param
Maximum number of basic blocks before VRP uses a sparse bitmap cache.
diff --git a/gcc/tree-vrp.cc b/gcc/tree-vrp.cc
index 26979b706e5..e184e9af51e 100644
--- a/gcc/tree-vrp.cc
+++ b/gcc/tree-vrp.cc
@@ -60,6 +60,7 @@ along with GCC; see the file COPYING3. If not see
#include "ipa-cp.h"
#include "ipa-prop.h"
#include "attribs.h"
+#include "diagnostic-core.h"
// This class is utilized by VRP and ranger to remove __builtin_unreachable
// calls, and reflect any resulting global ranges.
@@ -1331,9 +1332,18 @@ public:
unsigned int execute (function *fun) final override
{
// Check for fast vrp.
- if (&data == &pass_data_fast_vrp)
+ bool use_fvrp = (&data == &pass_data_fast_vrp);
+ if (!use_fvrp && last_basic_block_for_fn (fun) > param_vrp_block_limit)
+ {
+ use_fvrp = true;
+ warning (OPT_Wdisabled_optimization,
+ "Using fast VRP algorithm. %d basic blocks"
+ " exceeds %<--param=vrp-block-limit=%d%> limit",
+ n_basic_blocks_for_fn (fun),
+ param_vrp_block_limit);
+ }
+ if (use_fvrp)
return execute_fast_vrp (fun, final_p);
-
return execute_ranger_vrp (fun, final_p);
}
--
2.45.0