https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93023
Wilco <wilco at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wilco at gcc dot gnu.org --- Comment #1 from Wilco <wilco at gcc dot gnu.org> --- (In reply to Feng Xue from comment #0) > Analysis into ivopts shows that those address IVs have same in-loop cost, > and IV w/o offset does have smaller pre-loop setup cost. But since the setup > cost will be averaged to each iteration, the minor cost difference will go > due to round-off by integer division. To fix this round-off error, cost can > be represented in a more accurate way, such as adding a fraction part to > make it a fixpoint number. It would be easy to adjust the costs. There are a few places where address costs (multiples of 1) are incorrectly mixed with rtx costs (multiples of 4), so adjusting address costs should improve things. However I suspect the problem is also caused by using overly high iteration estimates and not taking codesize into account. If the loop costs are identical then you obviously choose the variant with the fewest instructions.