https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119280
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Funny I pointed to the same documentation as mentioned in the LLVM issue without seeing that. Again this is not a bug in GCC. If you want to do some really micro-benchmarking you will need to write everything in assembly so things won't move around. If you want to do some micro-benchmarking that is slightly more complex, you could have a function which is marked as noipa and then place the rdcycle around it. But this again is how inline-asm is defined. It is also not just the instruction scheduler which will move code around for this either.