This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Swap optimization pass


Jeffrey A Law writes:
> Hmmmm, you might start trying to catch a swap done in registers instead of
> memory just to see if we can make combine do the right thing.
> 
> Usually you don't have to write any special code to make combine use
> new instructions like this -- it works by just trying to cram together
> any instructions that are related via dataflow analysis.

The following is from combine.c:

   The LOG_LINKS of each insn identify the most recent assignment
   to each REG used in the insn.  It is a list of previous insns,
   each of which contains a SET for a REG that is used in this insn
   and not used or set in between.  LOG_LINKs never cross basic blocks.
   They were set up by the preceding pass (lifetime analysis).

   We try to combine each pair of insns joined by a logical link.
   We also try to combine triples of insns A, B and C when
   C has a link back to B and B has a link back to A.

If we have the following pseudo rtl:

  (set (reg 3) (reg 1))   insn B
  (set (reg 1) (reg 2))   insn A
  (set (reg 2) (reg 3))   insn C

Which describes a swap then there will be the following links:

  insn C -> insn B

Notice that there is no link from B -> A since reg 1 isn't set
until after insn B, and without this link combine will not try
to cram all three instructions together into something which
might match a swap insn.  Unfortunately instructions which equal
a swap just don't have a dataflow which matches the description
given in combine.c.  I may be missing something so I'll certainly
look at this further.

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]