Re: i386 flags register clober in inline assembly

Jan Hubicka (jh@suse.cz)
Tue, 20 Nov 2001 14:00:59 +0100


> On Sat, Nov 17, 2001 at 06:48:22PM -0800, Linus Torvalds wrote:
> > That sounds pretty ideal - have some way of telling gcc to add a "seta
> > %reg", while at the same time telling gcc that if it can elide the "seta"
> > and use a direct jump instead, do so..
>
> Hmm. It appears to be easy to do with machine-dependent builtins. E.g.
>
> int x;
> __asm__ __volatile__(LOCK "subl %1,%0"
> : "=m"(v->counter) : "ir"(i) : "memory");
> x = __builtin_ia32_sete();
> if (x) {
> ...
> }
>
> Now, you'd have to be careful in where that __builtin_ia32_sete
> gets placed, but I'd guess that immediately after an asm would
> be relatively safe. No 100% guarantees on that, unfortunately.
>
> And the sete _ought_ to get merged with the if test by combine
> or cse with no extra code.
>
> It wouldn't take too much effort to try this out either...
True. Only obstackle I see is how to make visible that the flags
are set by the asm statement. I guess we need to replace the clobber
we have by set. Do you have any idea for nice syntax for this?
Or just to do that by default, as asms are mostly non-single-set anyway?

Honza

>
>
> r~
-
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/