Re: i386 flags register clober in inline assembly

Jan Hubicka (jh@suse.cz)
Sun, 18 Nov 2001 02:09:57 +0100


>
> On Sat, 17 Nov 2001, Jan Hubicka wrote:
> >
> > Actually the main dificulty I see is storing cc0 to variable. CC0 is hard
> > register and pretty strange one - you can't move it, you can't spill.
>
> Well, you _can_ spill it, but you need to use "pushfl/popfl" to
> spill/restore.
I know, I can, but we are speaking about sollution how to get programs faster,
not slow down them to scrawl.
Sadly gcc's reload pass is one (or the) most tricky part of gcc and adding any
new feature to that beast is extreme problem, especially with later maitenance.

Actually what can be feasible is to make asm statement set flags and follow
it by store flag instruction that will be used in the conditional. Later
the combine pass should be able to get it connected.

Problem with this sollution I see is that it would need to redesign way
the conditionals are output. Currently gcc believes there is single flags
register and emits comparison and user of flags separately.

Backends plays around this and remembers the comparisons instead of emitting
and do use it later once asked for emitting the flags user. If the asm
statement is emit, backend would not be notified and whole machinery needs
to be tweaked.

Also I am not quite sure how to nicely design the syntax representing the
asm and flag store together.

The 3.1 feature freeze is in few weeks, not enought to implement something
so drastic, but I will try to keep it in the mind and discuss later for 3.2.

The design of asm statements should be IMO re-tought. I think it has been
mistake to make them so low level and allow user to write constraints directly,
so perhaps we can think about big change for future gcc...

Honza
>
> Also, if you're clever you don't spill cc0 itself, but the _comparison_,
> ie if you need to spill in
>
> asm(.. "=cc" (cc0))
> if (cc0 > 0)
>
> a sufficiently clever spill-engine would spill not eflags, but instead
> spill "cc0 > 0", which it can do with the "seq" expansions..
>
> gcc already does know about "store-flag" instructions, although I
> certainly agree that the _patterns_ of usage may end up being very
> different than existing conditional comparisons..
>
> Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/