https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117464
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- I am not 100% sure but I am suspecting there is some aliasing issues with the code. Does -fno-strict-aliasing fix the issue? I suspect you are writing and then reading via two different types to the same memory location which is causing issues.