https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67281
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- There is no memory access in your testcase at all. Since the variables are all local variables and nothing takes the address, it can be moved out of the loop as no other thread can cause that to fail.