https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67213
--- Comment #3 from Fredrik Hederstierna <fredrik.hederstie...@securitas-direct.com> --- Created attachment 36186 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36186&action=edit Dump from tree-ssa-loop-ivcanon.c In the function iter_6 it seems like it will keep cost 5 when unrolling. Maybe the weights and costs estimations could be more pessimistic when optimizing for size? I think functions tree_estimate_loop_size() and estimated_unrolled_size() uses a rough number guess of 1/3, perhaps it could be more pessimistic eg. for -Os?