Swap optimization pass

Jeffrey A Law law@cygnus.com
Wed Jan 28 18:51:00 GMT 1998


  In message < 199801290015.BAA07344@quatramaran.ens.fr >you write:
  > I first thought this to be pointless, as the 68k family certainly has
  > enough registers for gcc to work correctly, which seems to be the main
  > problem there, right ?
It's not a question of working correctly, but a question of does the
xchg instruction run faster or not?  If it does not run faster, does
the decrease in register pressure offset the xchg instruction running
slower than the equivalent move instructions.

Consider the case where using an xchg instruction allows the compiler
to remove the need for a register at a particular point.  This may
in turn decrease the overall register pressure in the function so
that the reload pass no longer has to spill registers, which would
be a big win.

Or maybe the xchg reduces pressure enough that its no longer necessary
to save/restore a callee saved register  in the prologue/epilgoue.

In general, reducing register pressure is a win (scheduling issues
aside, which is a valid assumption for gcc on 68ks).

The real question that has to be answered is does using a swap
instruction result in an overall improvement or not.  It really
doesn't matter to the end user if the overall improvement is from
primary or secondary effects.

jeff



More information about the Gcc-bugs mailing list