Hi,
This patch cleans get_computation* interfaces. Specifically, it removes
get_computation and get_computation_cost_at.
Is it OK?
Thanks,
bin
2017-04-11 Bin Cheng <bin.ch...@arm.com>
* tree-ssa-loop-ivopts.c (get_computation_at): Reorder parameters.
(get_computation): Delete.
(get_computation_cost): Implement like get_computation_cost_at.
Use get_computation_at.
(get_computation_cost_at): Delete.
(rewrite_use_nonlinear_expr): Use get_computation_at.
(rewrite_use_compare, remove_unused_ivs): Ditto.
From 6d34e0ad6d0ddfc9069f12e43f2fe801d4d65531 Mon Sep 17 00:00:00 2001
From: Bin Cheng <binch...@e108451-lin.cambridge.arm.com>
Date: Wed, 1 Mar 2017 10:39:18 +0000
Subject: [PATCH 08/33] clean-get_computation-interface-20170220.txt
---
gcc/tree-ssa-loop-ivopts.c | 56 ++++++++++++----------------------------------
1 file changed, 14 insertions(+), 42 deletions(-)
diff --git a/gcc/tree-ssa-loop-ivopts.c b/gcc/tree-ssa-loop-ivopts.c
index 5ab1d29..22c0ea5 100644
--- a/gcc/tree-ssa-loop-ivopts.c
+++ b/gcc/tree-ssa-loop-ivopts.c
@@ -3819,8 +3819,8 @@ get_use_type (struct iv_use *use)
CAND at statement AT in LOOP. The computation is unshared. */
static tree
-get_computation_at (struct loop *loop,
- struct iv_use *use, struct iv_cand *cand, gimple *at)
+get_computation_at (struct loop *loop, gimple *at,
+ struct iv_use *use, struct iv_cand *cand)
{
aff_tree aff;
tree type = get_use_type (use);
@@ -3831,15 +3831,6 @@ get_computation_at (struct loop *loop,
return fold_convert (type, aff_combination_to_tree (&aff));
}
-/* Determines the expression by that USE is expressed from induction variable
- CAND in LOOP. The computation is unshared. */
-
-static tree
-get_computation (struct loop *loop, struct iv_use *use, struct iv_cand *cand)
-{
- return get_computation_at (loop, use, cand, use->stmt);
-}
-
/* Adjust the cost COST for being in loop setup rather than loop body.
If we're optimizing for space, the loop setup overhead is constant;
if we're optimizing for speed, amortize it over the per-iteration cost. */
@@ -4807,18 +4798,17 @@ get_scaled_computation_cost_at (ivopts_data *data,
gimple *at, iv_cand *cand,
/* Determines the cost of the computation by that USE is expressed
from induction variable CAND. If ADDRESS_P is true, we just need
to create an address from it, otherwise we want to get it into
- register. A set of invariants we depend on is stored in
- INV_VARS. AT is the statement at that the value is computed.
+ register. A set of invariants we depend on is stored in INV_VARS.
If CAN_AUTOINC is nonnull, use it to record whether autoinc
- addressing is likely. */
+ addressing is likely. If INV_EXPR is nonnull, record invariant
+ expr entry in it. */
static comp_cost
-get_computation_cost_at (struct ivopts_data *data,
- struct iv_use *use, struct iv_cand *cand,
- bool address_p, bitmap *inv_vars, gimple *at,
- bool *can_autoinc,
- iv_inv_expr_ent **inv_expr)
+get_computation_cost (struct ivopts_data *data, struct iv_use *use,
+ struct iv_cand *cand, bool address_p, bitmap *inv_vars,
+ bool *can_autoinc, iv_inv_expr_ent **inv_expr)
{
+ gimple *at = use->stmt;
tree ubase = use->iv->base, ustep = use->iv->step;
tree cbase, cstep;
tree utype = TREE_TYPE (ubase), ctype;
@@ -5027,7 +5017,7 @@ fallback:
*can_autoinc = false;
/* Just get the expression, expand it and measure the cost. */
- tree comp = get_computation_at (data->current_loop, use, cand, at);
+ tree comp = get_computation_at (data->current_loop, at, use, cand);
if (!comp)
return infinite_cost;
@@ -5040,24 +5030,6 @@ fallback:
return get_scaled_computation_cost_at (data, at, cand, cost);
}
-/* Determines the cost of the computation by that USE is expressed
- from induction variable CAND. If ADDRESS_P is true, we just need
- to create an address from it, otherwise we want to get it into
- register. A set of invariants we depend on is stored in
- INV_VARS. If CAN_AUTOINC is nonnull, use it to record whether
- autoinc addressing is likely. */
-
-static comp_cost
-get_computation_cost (struct ivopts_data *data,
- struct iv_use *use, struct iv_cand *cand,
- bool address_p, bitmap *inv_vars,
- bool *can_autoinc, iv_inv_expr_ent **inv_expr)
-{
- return get_computation_cost_at (data,
- use, cand, address_p, inv_vars, use->stmt,
- can_autoinc, inv_expr);
-}
-
/* Determines cost of computing the use in GROUP with CAND in a generic
expression. */
@@ -7186,7 +7158,7 @@ rewrite_use_nonlinear_expr (struct ivopts_data *data,
}
}
- comp = get_computation (data->current_loop, use, cand);
+ comp = get_computation_at (data->current_loop, use->stmt, use, cand);
gcc_assert (comp != NULL_TREE);
switch (gimple_code (use->stmt))
@@ -7411,7 +7383,7 @@ rewrite_use_compare (struct ivopts_data *data,
/* The induction variable elimination failed; just express the original
giv. */
- comp = get_computation (data->current_loop, use, cand);
+ comp = get_computation_at (data->current_loop, use->stmt, use, cand);
gcc_assert (comp != NULL_TREE);
ok = extract_cond_operands (data, use->stmt, &var_p, NULL, NULL, NULL);
@@ -7552,8 +7524,8 @@ remove_unused_ivs (struct ivopts_data *data)
continue;
tree comp = get_computation_at (data->current_loop,
- &dummy_use, best_cand,
- SSA_NAME_DEF_STMT (def));
+ SSA_NAME_DEF_STMT (def),
+ &dummy_use, best_cand);
if (!comp)
continue;
--
1.9.1