This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: inline asm constraints for conditions
- From: Jamie Lokier <jamie at shareable dot org>
- To: Richard Henderson <rth at redhat dot com>, David Howells <dhowells at redhat dot com>, gcc at gcc dot gnu dot org
- Date: Mon, 29 Sep 2003 18:21:34 +0100
- Subject: Re: inline asm constraints for conditions
- References: <8873.1064599632@redhat.com> <20030926203935.GB21887@redhat.com>
Richard Henderson wrote:
> On Fri, Sep 26, 2003 at 07:07:12PM +0100, David Howells wrote:
> > Would it be possible to get a new type of inline asm constraint added, such
> > that a "condition" can be an output?
>
> Not like this, no.
>
> The most basic problem for x86 is that the flags register dies too often.
> If we were to add the ability for it to live longer and be reloaded (say
> with lahf/sahf), then generic parts of the compiler would start trying to
> make use of it, which would almost certainly result in worse code overall
> even when the feature was not in use.
Why does it need the ability to be reloaded the whole flags?
If the flags register is killed, then "reloading" should be a simple
matter of either redoing the comparison, as effectively happens all
the time now, or saving the _particular_ comparison results that are
wanted using setcc, sbbl etc. into an ordinary register.
Would it work to define a multitude of condition registers on the x86,
one for each branch condition, like this:
1. cmp/sub set all the condition registers.
2. other flags-affecting instructions clobber all the condition
registers or (in the case of inc/dec) just some of them.
3. branches and other conditionals use one of the many
condition registers.
4. reload "moves" one condition register _to_ a general register
or memory using setcc/sbb.
5. reload "moves" one condition register _from_ a general
register or memory by doing a comparison against the saved
value to set the real flags again.
Of course this clobbers all the other condition registers :)
Would this work?
-- Jamie