https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98931
--- Comment #7 from Jakub Jelinek <jakub at gcc dot gnu.org> --- I don't think one can use get_attr_length until very late, at least definitely not reliably, distances can shrink or grow a lot by other passes. Is there some reason why the doloop_end insn pattern can't do what other conditional jumps do, in particular have the length attribute on themselves determine if they can use a short or long form and in the long form do unconditional branches in addition to the conditional ones? I guess one can't invert this insn, so if it is out of bounds, one would probably need to le 1f; b 2f; 1: b lab; 2: or so instead of le lab if lab is too far. Walking all insns in between (especially when you don't give up when you reach the limit) can increase compile time complexity on some functions too.