[PATCH] reload: Try alternative with swapped operands before going to the next

Ulrich Weigand uweigand@de.ibm.com
Mon Apr 23 15:15:00 GMT 2012


Uros Bizjak wrote:
> > 2011-11-17  Andreas Krebbel  <Andreas.Krebbel@de.ibm.com>
> >
> > 	* reload.c (find_reloads): Change the loop nesting when trying an
> > 	alternative with swapped operands.
> 
> I would just like to point out that constran_operands will have
> problems to re-recognize alternative with swapped commutative
> operands. The "%" operand modifier is ignored there, so i.e. x86 add
> pattern with swapped commutative operands, like:
> 
> (set (reg: ax) (plus (reg: bx)(reg: ax)))
> 
> will be rejected.

Well, yes, that's why reload explicitly tries both versions, and
keeps the one that matches ...

The only thing Andreas' patch changes is the priority in which
different options are tried if there are multiple alternatives.

For example, if you have a pattern that has commutative operands,
and one of them supports both register and memory, reload can
try:

 1.) use operands as they are
 2.) spill one operand to memory
 3.) swap operands
 4.) swap operands and spill one operand to memory

It used to be that reload tried these in order 1, 2, 3, 4;
with Andreas' patch they are now tried in order 1, 3, 2, 4.
(Always assuming there are no priorities like ! or ? specified
in the .md file.  Those would override in either case.)


Could you explain in more detail the problem you see with that?

Bye,
Ulrich

-- 
  Dr. Ulrich Weigand
  GNU Toolchain for Linux on System z and Cell BE
  Ulrich.Weigand@de.ibm.com



More information about the Gcc-patches mailing list