https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127824
--- Comment #3 from Manuel López-Ibáñez <manu at gcc dot gnu.org> --- Sorry, I thought I had tried -ffast-math but it seems I didn't. Clang has a new builtin to help in these cases: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-assume-dereferenceable
