Subject: RE: gcc assembler issues
To: Toru Nishimura <locore32@gaea.ocn.ne.jp>
From: Maciej W. Rozycki <macro@ds2.pg.gda.pl>
List: port-pmax
Date: 07/01/2002 16:04:19
On Sat, 29 Jun 2002, Toru Nishimura wrote:

> > Ok, so I've compiled with the -S (instead of -c) option. And interpret.s
> > works out the same. Line 28764 says this:
> >
> >   j       $L3655
> > ...
> > I wonder if a newer GCC has this issue fixed.
> 
> This is not a compiler bug in strict senses, but the program hits a limitation of
> hardware.  J(ump) instruction takes 28bit target which happens not to cope
> with the program.  The limitation does not matter for most cases as long as
> functions are small enough.   Jumbo functions are very harmful for fast
> compilation because optimizer spends much longer time to sweep around and
> often results in poor register assignment for runtime.  Rather better to fix the
> program side for public benefits.

 Since the program is likely compiled as PIC, a "j label" instruction is
silently translated to "b label" (or actually "beq $zero, $zero, label",
as there is no "real" unconditional branch opcode) and the limitation is
much smaller -- actually +/- 128KB (18 bits).  This is a longstanding lack
of a feature in gas and is currently on my to-do list.  A fix would
require a use of a branch with an inverted condition to skip past a jump
register instruction (plain jump for non-PIC).  For an unconditional
branch a lone jump register would suffice. 

 I haven't been hit by the problem so far, so it's not high-priority for
me -- anyone feel free to code a fix for gas. 

  Maciej

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: macro@ds2.pg.gda.pl, PGP key available        +