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

--- Comment #8 from Alexander Monakov <amonakov at gcc dot gnu.org> ---
Unfortunately the above doesn't fully address the issue, as schedulers and
other passes still have no idea that DF makes those assumptions and will allow
reordering of asms:

register int r asm("ebx");

int f(int x, int y)
{
    int t = x/y/r;
    asm("#asm" );
    return t-x;
}

_Z1fii:
#APP
        #asm
#NO_APP
        movl    %edi, %eax
        cltd
        idivl   %esi
        cltd
        idivl   %ebx
        subl    %edi, %eax
        ret

See how the asm is first, even though from DF point of view it should remain
after the read of %ebx for division by r; here cprop_hardreg makes the
offending propagation.

So currently GCC has a rather split personality when it comes to deps w.r.t
global reg vars in asm statements. The documentation should spell out the
intended behavior. My suggestion is to require that references are exposed to
the compiler via constraints, allowing to remove the ad-hoc treatment in DF. I
intend to do that early in stage 1.

Reply via email to