This is the mail archive of the gcc@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: inline asm constraints for conditions


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


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