https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119280
--- Comment #3 from Huaqi <fanghuaqi at vip dot qq.com> --- (In reply to Andrew Pinski from comment #1) > https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Extended-Asm.html#Volatile-1 > > Note that the compiler can move even volatile asm instructions relative to > other code, including across jump instructions. For example, on many targets > there is a system register that controls the rounding mode of floating-point > operations. Setting it with a volatile asm statement, as in the following > PowerPC example, does not work reliably. > > ... So this is an expected behavior and won't be fixed? And if I want to have to benchmark a piece of code using riscv's cycle csr via inline asm code, it will be really strange to give an incorrect value. Same issue existed in llvm, see https://github.com/llvm/llvm-project/issues/130033