https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82602
--- Comment #11 from Segher Boessenkool <segher at gcc dot gnu.org> --- (In reply to Bernd Edlinger from comment #10) > Yes, and moreover foo() could access non-volatile memory. > And only a memory clobber can prevent the compiler from > using cached values. But you *want* the compiler to use cached values if it can. It is valid for the compiler to move all of foo (or part of it) to outside the asm's, if the compiler can see the body of foo, e.g. with LTO or if it is defined in this translation unit. That's what makes this code not so super. There should _not_ be a memory clobber in these asm statements. Memory clobbers do not prevent using cached values, btw.; not in the general case, anyway. A memory clobber says "this asm may write to some memory, and I'm not saying what". It does not force things to live in memory, and it does do nothing to things in registers.