https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114923
--- Comment #6 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Some resources about memory barriers and why they are needed here (for both HW and SW): https://en.wikipedia.org/wiki/Memory_barrier https://www.kernel.org/doc/Documentation/memory-barriers.txt https://www.oreilly.com/library/view/linux-device-drivers/0596005903/ch09.html And many more.