This is the mail archive of the gcc-patches@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]
Other format: [Raw text]

Re: [PATCH, x86_64]: Provide longlong.h definitions for 128bit operations


On Tue, May 22, 2007 at 07:26:50PM +0200, Roman Zippel wrote:
> Hi,
> 
> On Fri, 18 May 2007, Ian Lance Taylor wrote:
> 
> > >From the backend perspective, the best way to take advantage of
> > lower-subreg is conceptually simple if sometimes awkward in practice:
> > for multi-word operations, use define_insn_and_split and split the
> > insns before reload.
> 
> I'm playing around with it a little on m68k and there is sometimes a bit 
> of a conflict. E.g. I would split somthing like adddi3/subdi3 already 
> before combine, because the addx/subx instruction is much more limited in 
> its addressing mode (only accepts register), so combine can generate the 
> right instructions.

   It can be done:

1) Define predicates and constraints which match the available addressing
modes.
2) Define an insn(_and_split) which uses those predicates and constraints.
3) Define an insn similiar to the one in 2), but where the (mem ...)
expression is not an operand. Instead, you have something like

	... (mem:SI (match_operand:SI "register_operand" "a"))

4) Split the insn in 2) to the one in 3) before reload.
5) Put the insn in 3) before the one in 2) in the .md file.

   I think that since the address is so simple in this case, you can skip
part 1), 2), 4) and 5). Just be careful that you don't use the template in
3) as an output template, or you'll lose the alias set.

(The danger of losing the alias set really ought to be documented.)

> 	unsigned long long x, y;
> 	return x + (y >> 63);
> 
> is better handled as:
> 
> 	unsigned long long x, y;
> 	return x - ((long long)y >> 63);

   Interesting optimization when signed shifts are faster than unsigned
ones.

> In this context I'm curious about another problem, how should it work in 
> general (i.e. independent of cc0) to combine a subdi/cmpdi or subdi/tstdi 
> pattern?

   Combine will do this automatically if you define the insn to do so. In
this case, it will just be a define_insn_and_split instead of the usual
define_insn, but that makes no difference to combine. If your question is
how to write the combined patterns in general, see
<URL:http://gcc.gnu.org/ml/gcc/2004-02/msg00903.html>.

   You will have to define a CCmode for the multi-word instructions since
the zero flag won't be usable. You'll therefore also have to delay the
output of the comparison instruction until you know the comparison operator.
This is documented in the GCC Internals manual.

   (Also check that your overflow flag is set to something useful.)

-- 
Rask Ingemann Lambertsen


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