Hi, This was lost in the original microMIPS submission.
For absolute microMIPS jumps GCC always produces a branch instruction, causing a `relocation truncated to fit: R_MICROMIPS_PC16_S1' linker error if the branch target turns out of range. The TARGET_ABICALLS_PIC2 macro is never set in absolute code. This is the only RTL pattern that we have that does not handle this case correctly, all the other ones set the type of the pattern to "branch" and rely on instruction length calculation to see if branch relaxation would trigger on not. If so, then they produce an appropriate jump instruction. So do it here as well; this affects the standard mode too (branches are now always produced whenever in range), but IMHO in a good or at least neutral way. Regression-tested with the mips-linux-gnu target and these multilibs: -EB -EB -mips16 -EB -mmicromips -EB -mabi=n32 -EB -mabi=64 and the -EL variants of same, fixing these failures: g++.dg/opt/longbranch1.C -std=gnu++11 (test for excess errors) g++.dg/opt/longbranch1.C -std=gnu++14 (test for excess errors) g++.dg/opt/longbranch1.C -std=gnu++98 (test for excess errors) across microMIPS multilibs, e.g.: FAIL: g++.dg/opt/longbranch1.C -std=gnu++11 (test for excess errors) Excess errors: longbranch1.C:(.text+0x15092): relocation truncated to fit: R_MICROMIPS_PC16_S1 against `$L2' No other changes in test results. OK to apply? 2014-11-17 Maciej W. Rozycki <ma...@codesourcery.com> gcc/ * gcc/config/mips/mips.md (*jump_absolute): Use a branch when in range, a jump otherwise. Maciej gcc-mips-jump-branch.diff Index: gcc-fsf-trunk-quilt/gcc/config/mips/mips.md =================================================================== --- gcc-fsf-trunk-quilt.orig/gcc/config/mips/mips.md 2014-11-16 19:54:17.000000000 +0000 +++ gcc-fsf-trunk-quilt/gcc/config/mips/mips.md 2014-11-17 04:44:32.847732003 +0000 @@ -5957,14 +5957,12 @@ (label_ref (match_operand 0)))] "!TARGET_MIPS16 && TARGET_ABSOLUTE_JUMPS" { - /* Use a branch for microMIPS. The assembler will choose - a 16-bit branch, a 32-bit branch, or a 32-bit jump. */ - if (TARGET_MICROMIPS && !TARGET_ABICALLS_PIC2) + if (get_attr_length (insn) <= 8) return "%*b\t%l0%/"; else return MIPS_ABSOLUTE_JUMP ("%*j\t%l0%/"); } - [(set_attr "type" "jump")]) + [(set_attr "type" "branch")]) (define_insn "*jump_pic" [(set (pc)