https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94665
--- Comment #2 from Segher Boessenkool <segher at gcc dot gnu.org> --- If vara is a NaN, this is not the same; it needs -ffinite-math-only. And in fact adding that option does the trick (on powerpc that is, I don't have an aarch64 Fortran handy). Could you check this please?