Compiler memory barriers has the effect among other things to force the compiler to make sure all stack variables that are cached in registers are written t
Try with { int y = x; *(volatile int*)&x = y; } and inspect the resulting assembly.
{ int y = x; *(volatile int*)&x = y; }