Re: x87 register clobber returns "unknown register name" error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Le 15/10/2015 11:29, Segher Boessenkool a écrit :
> I'm not sure you can clobber stack regs at all.  You could add it as
> an output and just not use the result?  Like
>
> asm ("fyl2xp1" : "=t" (result), "=u" (dummy) : "0" (x), "1" (y));
>
>
> Segher

Indeed, this compiles and works as intended :

    float st0; // Will not be used, just a way to clobber the
floating-point stack
    asm volatile ("fstps (%2)" :
                  "=t" (st0) :
                  "0" (input), "r" (output) :
                  "memory");

And for the code aesthetes out there, I can also think of a version that
looks better and uses less storage, at the cost of erasing input :

    asm volatile ("fstps (%2)" :
                  "+t" (input) :
                  "r" (output) :
                  "memory");

One thing that makes me sad is that GCC might perform a useless x87
stack pop (depending on how clever its optimizer is), which can become
an issue in a performance-sensitive code path.

Another is that the documentation suggests that it is possible to
clobber stack registers (at the very bottom of
https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#OutputOperands ),
whereas it seems impossible in practice. So I guess that either the
ability to clobber stack registers should be added to GCC, or the
documentation should be fixed to reflect this situation.

Hadrien



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux