* [COMMITTED 5/5] Make compute_operand_range a tail call.
@ 2023-07-05 23:08 Andrew MacLeod
0 siblings, 0 replies; only message in thread
From: Andrew MacLeod @ 2023-07-05 23:08 UTC (permalink / raw)
To: gcc-patches; +Cc: hernandez, aldy
[-- Attachment #1: Type: text/plain, Size: 302 bytes --]
This simply tweaks cmpute_operand_range a little so the recursion is a
tail call.
With this, the patchset produces a modest speedup of 0.2% in VRP and
0.4% in threading. It will also have a much smaller stack profile.
Bootstraps on x86_64-pc-linux-gnu with no regressions. Pushed.
Andrew
[-- Attachment #2: 0005-Make-compute_operand_range-a-tail-call.patch --]
[-- Type: text/x-patch, Size: 2584 bytes --]
From 51ed3a6ce432e7e6226bb62125ef8a09b2ebf60c Mon Sep 17 00:00:00 2001
From: Andrew MacLeod <amacleod@redhat.com>
Date: Wed, 5 Jul 2023 14:26:00 -0400
Subject: [PATCH 5/6] Make compute_operand_range a tail call.
Tweak the routine so it is making a tail call.
* gimple-range-gori.cc (compute_operand_range): Convert to a tail
call.
---
gcc/gimple-range-gori.cc | 34 ++++++++++++++++------------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/gcc/gimple-range-gori.cc b/gcc/gimple-range-gori.cc
index b036ed56f02..6dc15a0ce3f 100644
--- a/gcc/gimple-range-gori.cc
+++ b/gcc/gimple-range-gori.cc
@@ -725,36 +725,34 @@ gori_compute::compute_operand_range (vrange &r, gimple *stmt,
op1_trange, op1_frange, op2_trange, op2_frange);
if (idx)
tracer.trailer (idx, "compute_operand", res, name, r);
+ return res;
}
// Follow the appropriate operands now.
- else if (op1_in_chain && op2_in_chain)
- res = compute_operand1_and_operand2_range (r, handler, lhs, name, src,
- vrel_ptr);
- else if (op1_in_chain)
+ if (op1_in_chain && op2_in_chain)
+ return compute_operand1_and_operand2_range (r, handler, lhs, name, src,
+ vrel_ptr);
+ Value_Range vr;
+ gimple *src_stmt;
+ if (op1_in_chain)
{
- Value_Range vr (TREE_TYPE (op1));
+ vr.set_type (TREE_TYPE (op1));
if (!compute_operand1_range (vr, handler, lhs, src, vrel_ptr))
return false;
- gimple *src_stmt = SSA_NAME_DEF_STMT (op1);
- gcc_checking_assert (src_stmt);
- // Then feed this range back as the LHS of the defining statement.
- return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr);
+ src_stmt = SSA_NAME_DEF_STMT (op1);
}
- else if (op2_in_chain)
+ else
{
- Value_Range vr (TREE_TYPE (op2));
+ gcc_checking_assert (op2_in_chain);
+ vr.set_type (TREE_TYPE (op2));
if (!compute_operand2_range (vr, handler, lhs, src, vrel_ptr))
return false;
- gimple *src_stmt = SSA_NAME_DEF_STMT (op2);
- gcc_checking_assert (src_stmt);
- // Then feed this range back as the LHS of the defining statement.
- return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr);
+ src_stmt = SSA_NAME_DEF_STMT (op2);
}
- else
- gcc_unreachable ();
+ gcc_checking_assert (src_stmt);
+ // Then feed this range back as the LHS of the defining statement.
+ return compute_operand_range (r, src_stmt, vr, name, src, vrel_ptr);
// If neither operand is derived, this statement tells us nothing.
- return res;
}
--
2.40.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-07-05 23:08 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 23:08 [COMMITTED 5/5] Make compute_operand_range a tail call Andrew MacLeod
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).