diff options
author | Kewen Lin <linkw@gcc.gnu.org> | 2019-09-14 09:01:21 +0000 |
---|---|---|
committer | Kewen Lin <linkw@gcc.gnu.org> | 2019-09-14 09:01:21 +0000 |
commit | 603a4ad49978d2a967a1996ac626531200553715 (patch) | |
tree | 4cee5f4426954435348cd0b29cd6f982a463318a /gcc/target.def | |
parent | f3898644854c846c3d28d6b2300bf40283d88c94 (diff) |
Consider doloop IV in IVOPTs
For the targets supporting low-overhead loops, IVOPTs has to take care of
the loops which will probably be transformed in RTL doloop optimization,
to try to make selected IV candidate set optimal. The process of doloop
support includes:
1) Analyze the current loop will be transformed to doloop or not, find and
mark its compare type IV use as doloop use (iv_group field doloop_p), and
set flag doloop_use_p of ivopts_data to notify subsequent processings on
doloop. See analyze_and_mark_doloop_use and its callees for the details.
The target hook predict_doloop_p can be used for target specific checks.
2) Add one doloop dedicated IV cand {(may_be_zero ? 1 : (niter + 1)), +, -1},
set flag doloop_p of iv_cand, step cost is set as zero and no extra cost
like biv. For cost determination between doloop IV cand and IV use, the
target hooks doloop_cost_for_generic and doloop_cost_for_address are
provided to add on extra costs for generic type and address type IV use.
Zero cost is assigned to the pair between doloop IV cand and doloop IV
use, and bound zero is set for IV elimination.
3) With the cost setting in step 2), the current cost model based IV
selection algorithm will process as usual, pick up doloop dedicated IV if
profitable.
gcc/ChangeLog
2019-09-14 Kewen Lin <linkw@gcc.gnu.org>
PR middle-end/80791
* config/rs6000/rs6000.c (TARGET_HAVE_COUNT_REG_DECR_P): New macro.
(TARGET_DOLOOP_COST_FOR_GENERIC): Likewise.
(TARGET_DOLOOP_COST_FOR_ADDRESS): Likewise.
* target.def (have_count_reg_decr_p): New hook.
(doloop_cost_for_generic): Likewise.
(doloop_cost_for_address): Likewise.
* doc/tm.texi.in (TARGET_HAVE_COUNT_REG_DECR_P): Likewise.
(TARGET_DOLOOP_COST_FOR_GENERIC): Likewise.
(TARGET_DOLOOP_COST_FOR_ADDRESS): Likewise.
* doc/tm.texi: Regenerate.
* tree-ssa-loop-ivopts.c (comp_cost::operator+=): Consider infinite cost
addend.
(record_group): Init doloop_p.
(add_candidate_1): Add optional argument doloop, change the handlings
accordingly.
(add_candidate): Likewise.
(generic_predict_doloop_p): Update attribute.
(force_expr_to_var_cost): Add costing for expressions COND_EXPR/LT_EXPR/
LE_EXPR/GT_EXPR/GE_EXPR/EQ_EXPR/NE_EXPR/UNORDERED_EXPR/ORDERED_EXPR/
UNLT_EXPR/UNLE_EXPR/UNGT_EXPR/UNGE_EXPR/UNEQ_EXPR/LTGT_EXPR/MAX_EXPR/
MIN_EXPR.
(get_computation_cost): Update for doloop IV cand extra cost.
(determine_group_iv_cost_cond): Update for doloop IV cand.
(determine_iv_cost): Likewise.
(ivopts_estimate_reg_pressure): Likewise.
(may_eliminate_iv): Update handlings for doloop IV cand.
(add_iv_candidate_for_doloop): New function.
(find_iv_candidates): Call function add_iv_candidate_for_doloop.
(iv_ca_set_no_cp): Update for doloop IV cand.
(iv_ca_set_cp): Likewise.
(iv_ca_dump): Dump register cost.
(find_doloop_use): New function.
(analyze_and_mark_doloop_use): Likewise.
(tree_ssa_iv_optimize_loop): Call function analyze_and_mark_doloop_use.
gcc/testsuite/ChangeLog
2019-09-14 Kewen Lin <linkw@gcc.gnu.org>
PR middle-end/80791
* gcc.dg/tree-ssa/ivopts-3.c: Adjust for doloop change.
* gcc.dg/tree-ssa/ivopts-lt.c: Likewise.
* gcc.dg/tree-ssa/pr32044.c: Likewise.
From-SVN: r275713
Diffstat (limited to 'gcc/target.def')
-rw-r--r-- | gcc/target.def | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/gcc/target.def b/gcc/target.def index 825c1e6d307..01609136848 100644 --- a/gcc/target.def +++ b/gcc/target.def @@ -4225,6 +4225,39 @@ The default version of this hook returns false.", bool, (class loop *loop), default_predict_doloop_p) +DEFHOOKPOD +(have_count_reg_decr_p, + "Return true if the target supports hardware count register for decrement\n\ +and branch.\n\ +The default value is false.", + bool, false) + +DEFHOOKPOD +(doloop_cost_for_generic, + "One IV candidate dedicated for doloop is introduced in IVOPTs, we can\n\ +calculate the computation cost of adopting it to any generic IV use by\n\ +function get_computation_cost as before. But for targets which have\n\ +hardware count register support for decrement and branch, it may have to\n\ +move IV value from hardware count register to general purpose register\n\ +while doloop IV candidate is used for generic IV uses. It probably takes\n\ +expensive penalty. This hook allows target owners to define the cost for\n\ +this especially for generic IV uses.\n\ +The default value is zero.", + int64_t, 0) + +DEFHOOKPOD +(doloop_cost_for_address, + "One IV candidate dedicated for doloop is introduced in IVOPTs, we can\n\ +calculate the computation cost of adopting it to any address IV use by\n\ +function get_computation_cost as before. But for targets which have\n\ +hardware count register support for decrement and branch, it may have to\n\ +move IV value from hardware count register to general purpose register\n\ +while doloop IV candidate is used for address IV uses. It probably takes\n\ +expensive penalty. This hook allows target owners to define the cost for\n\ +this escpecially for address IV uses.\n\ +The default value is zero.", + int64_t, 0) + DEFHOOK (can_use_doloop_p, "Return true if it is possible to use low-overhead loops (@code{doloop_end}\n\ |