After f9f69dd, complexity is calculated using the valid_mem_ref_p target hook. Architectures like Mips only allow BASE + OFFSET addressing modes, which in turn prevents the calculation of complexity for other addressing modes, resulting in non-optimal candidate selection.
There still is code that adjusts the address cost for unsupported addressing modes, however, it only adjusts the cost part (the complexity part is left at 0). gcc/ChangeLog: * tree-ssa-loop-ivopts.cc (get_address_cost): Calculate complexity for unsupported addressing modes as well. Signed-off-by: Dimitrije Milosevic <dimitrije.milose...@syrmia.com> --- gcc/tree-ssa-loop-ivopts.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/tree-ssa-loop-ivopts.cc b/gcc/tree-ssa-loop-ivopts.cc index ebd4aecce37..60c61dc9e49 100644 --- a/gcc/tree-ssa-loop-ivopts.cc +++ b/gcc/tree-ssa-loop-ivopts.cc @@ -4778,10 +4778,14 @@ get_address_cost (struct ivopts_data *data, struct iv_use *use, comp_inv = aff_combination_to_tree (aff_inv); if (comp_inv != NULL_TREE) cost = force_var_cost (data, comp_inv, inv_vars); - if (ratio != 1 && parts.step == NULL_TREE) + if (ratio != 1 && parts.step == NULL_TREE) { var_cost += mult_by_coeff_cost (ratio, addr_mode, speed); - if (comp_inv != NULL_TREE && parts.index == NULL_TREE) + var_cost.complexity += 1; + } + if (comp_inv != NULL_TREE && parts.index == NULL_TREE) { var_cost += add_cost (speed, addr_mode); + var_cost.complexity += 1; + } if (comp_inv && inv_expr && !simple_inv) { -- 2.25.1