Re: Inline asm - unexpected optimization

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

 



> gcc doesn't know anything special about rdtsc.  We would have to see the
> code to understand the difference.
My bad here, sorry.  My experiment was incorrect. I rechecked it and
rdtsc is indeed treated the same way as rdrand.

> For your example, the second rdrand instruction is removed by the
> common-subexpression-elimination pass.  By default gcc assumes that an
> asm instruction reads nothing other than its inputs and changes only its
> outputs.  By that reasoning, your second rdrand instruction will produce
> exactly the same result as your first one, so there is no need for it,
> so gcc eliminates it.  The volatile qualifier tells gcc that the asm
> instruction does something which is not explicitly expressed in the
> inputs and outputs.
Thank you Ian, Georg and Segher for the helpful explanations - its clear now.



[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