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(-)
@@ -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