diff mbox series

Fix bfin length computation

Message ID b0d9a56d-89ab-dae0-1af0-b08cde46a024@redhat.com
State New
Headers show
Series Fix bfin length computation | expand

Commit Message

Jeff Law March 24, 2019, 7:28 p.m. UTC
bfin-elf started failing in my tester a couple weeks ago.  Bisection
pointed to Richi's recent DOM change, but it was pretty clear that was
just exposing a backend issue.

The failure mode was the assembler compiling about an out-of-range
relocation for a pc-relative conditional jump when compiling vfprintf in
newlib.

bfin has multi-sized pc-relative branches and relies on the compiler to
compute lengths and shorten branches.  Totally standard.  It was pretty
obvious when looking at the assembler listing output for a "-dp"
compiled source.  We had an insn with l=2 which was 4 bytes long.  Thus
we slightly under-calculated the distance between the conditional branch
and its target and issued a short jump instead of a long jump.

I've never done anything with the bfin port, but this looks to be a very
safe way to address the problem.  It's just the first alternative in the
movpdi pattern.  It is marked with type "move" which always computes
size 2.  AFAICT this pattern+alternative combination is used for moves
between the accumulator registers and should always be 4 bytes long.

So I just explicitly set the length to 4 for that alternative and let
the other alternatives continue to compute their length via the default
mechanisms.

With this patch bfin returns to a working state in my tester.
Committing to the trunk.


Jeff
diff mbox series

Patch


	* config/bfin/bfin.md (movpdi): Fix length for alternative 1.

index 11c7c9ecd24..ac589242413 100644
--- a/gcc/config/bfin/bfin.md
+++ b/gcc/config/bfin/bfin.md
@@ -557,6 +557,7 @@ 
    %0 = %x1; %0 = %w1;
    %w0 = %1; %x0 = %1;"
   [(set_attr "type" "move,mcst,mcld")
+   (set_attr "length" "4,*,*")
    (set_attr "seq_insns" "*,multi,multi")])
 
 (define_insn "load_accumulator"