In article <20011117161436.B23331@atrey.karlin.mff.cuni.cz> you write:>They don't need to be. On i386, the flags are (partly for historical reasons) clobbered>by default.

However, this is one area where I would just be tickled pink if gcc wereto allow asm's to return status in eflags, even if that means that weneed to fix all our existing asms.

We have some really _horrid_ code where we use operations thatintrinsically set the flag bits, and we actually want to use them.Using things like cmpxchg, and atomic decrement-and-test-with-zero havethese horrid asm statements that have to move the eflags value (usuallyjust one bit) into a register, so that we can tell gcc where it is.

Where we first get the value we _really_ want in ZF in eflags, then weuse "sete" to move it to a register, and then gcc will end up generatingcode to test that register by hand, so the end result is usuallysomething like:

#APP lock ; decl 20(%edi); sete %al#NO_APP testb %al, %al je .L1570

even though what we'd _want_ is really

lock ; decl 20(%edi) jne .L1570

which is not only smaller and faster, but is often _really_ fasterbecause at least some Intel CPU's will forward the flags values to thebranch prediction stuff, and going through a register dependency willadd non-forwarded state and thus extra cycles.

So I would personally _really_ really like for some way to expose theinternal gcc

"(set (cc0) ..asm..)"

construct, together with some way of setting the cc_status.flags.

>From what I can tell, all the x86 machine description already uses "cc0"together with the notion of comparing it to zero (either signed orunsigned), so something like this _might_ just work

I know this used to be impossible in gcc, because the x86 didn'tactually track the flags values, and conditional jumps were really a_combination_ of the conditional and the jump, and splitting it up sothat the conditional would be in an asm was thus not possible.

But I think gcc makes cc0 explicit on x86 these days, and that the abovekind of setup might be possible today, no?