https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71231
--- Comment #11 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Andrew Pinski from comment #8) > This code has the following warning: > !CRAY - The following multiply must be done with 64 bits (not 46 bits) > ! The algoritm depends on the overflow characteristics of > ! a 32 or 64 bit multiply. > > > So the code is implicitly saying it needs to be done using overflow as > wrapping for signed integer but in Fortran, overflow is undefined. Indeed, "-Ofast -fwrapv" fixes run time and produces the correct result.