[Bug tree-optimization/17884] asm 'volatile' is not honored as documented

rth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Thu Jan 20 01:33:00 GMT 2005


------- Additional Comments From rth at gcc dot gnu dot org  2005-01-20 01:33 -------
In reply to comment #20:

Again, this is not scheduling, per se.  This is register
rematerialization.  We have a value at some point, and we
decide that it's cheaper to move the computation rather
than store and reload it.

This is really no different than if we decided to CSE the
computation as in

    __fnstsw(&s1);
    __fldenv(envp->x87);            /* volatile */
    __fnstsw(&s2);
->
    __fnstsw(&s1);
    __fldenv(envp->x87);            /* volatile */
    s2 = s1;

I must repeat myself that the original source code is 
buggy.  You've got asms that affect, or are affected by,
architectural state that is not visible to the compiler.
As such you REALLY REALLY MUST mark the asm as volatile.

-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17884



More information about the Gcc-bugs mailing list