[RFC] RISC-V: Raise noce if-conversion cost limit
wangjue <[email protected]> Fri, 7 Aug 2026 13:53:49 +0800
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <[email protected]> |
From: juewang <[email protected]> The branch-cost based noce limit is too small for unpredictable branches on C950 and blocks profitable Zicond sequences. Add a per-tune factor, defaulting to one, and use five for C950. This improves 505.mcf_r by nearly 5% on C950. gcc/ChangeLog: * config/riscv/riscv.cc (riscv_tune_param): Add noce_ifcvt_unpredictable_cost_factor. (xt_c9501_tune_info): Set it to 5. (riscv_max_noce_ifcvt_seq_cost): Scale the branch-cost based limit. --- gcc/config/riscv/riscv.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 6593d00a7e6..69cff996f5e 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -305,6 +305,7 @@ struct riscv_tune_param unsigned short vec_reassoc_width = 1; unsigned int small_loop_unroll_ninsns = 4; unsigned int small_loop_unroll_factor = 2; + unsigned short noce_ifcvt_unpredictable_cost_factor = 1; }; @@ -747,6 +748,7 @@ static const struct riscv_tune_param xt_c9501_tune_info = { 1, /* vec_reassoc_width. */ 4, /* small_loop_unroll_ninsns. */ 8, /* small_loop_unroll_factor. */ + 5, /* noce_ifcvt_unpredictable_cost_factor. */ }; /* Costs to use when optimizing for Tenstorrent Ascalon 8 wide. */ @@ -5130,7 +5132,9 @@ riscv_max_noce_ifcvt_seq_cost (edge e) return param_max_rtl_if_conversion_unpredictable_cost; } - return COSTS_N_INSNS (BRANCH_COST (true, predictable_p)); + return (BRANCH_COST (true, predictable_p) + * COSTS_N_INSNS + (tune_param->noce_ifcvt_unpredictable_cost_factor)); } /* Implement TARGET_NOCE_CONVERSION_PROFITABLE_P. We replace the cost of a -- 2.34.1