[Bug inline-asm/68095] "cc" clobber with Flag Output Operands

gccbugzilla at limegreensocks dot com gcc-bugzilla@gcc.gnu.org
Mon Nov 9 02:51:00 GMT 2015


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68095

--- Comment #3 from David <gccbugzilla at limegreensocks dot com> ---
> "=@ccc"(r) does not output to the "cc" register, it 
> outputs to a general register.  

Actually, I don't believe it does.

In v5, you *did* have to use "setc %0" with a general register AND it generated
an extra "cmp" instruction (very irritating).  But this code:

    int main()
    {
       int x;

       do {
          asm volatile("setc" : "=@ccc"(x) : : "cc");
       } while (!x);
    }

Compiled with -O2, now outputs:

    .L2:
    /APP
        setc
    /NO_APP
        jnc     .L2

No general register required.  It really is just using the flags.  

So it still looks to me like we are both clobbering flags (implying that they
are changed but not output) and outputting them.  Allowing both at once seems
bad.

> The "cc" clobber is not deprecated, not on other targets anyway.

As I look at final_scan_insn() in final.c, it appears to always call
CC_STATUS_INIT for both basic and extended asm.  And while not all platforms
may implement CC_STATUS_INIT, my assumption was that if the platform supported
the "cc" clobber, this was where the implementation was.

If there is no way to NOT clobber, then "cc" becomes an unenforced comment,
rather than a directive to change the behavior of the compiler.  If that's
true, updating the docs to say so seems reasonable.


More information about the Gcc-bugs mailing list