https://gcc.gnu.org/bugzilla/show_bug.cgi?id=108922
--- Comment #12 from Uroš Bizjak <ubizjak at gmail dot com> --- (In reply to Jan Kratochvil from comment #8) > The revert makes it 13x faster. But the produced code still falls back to > calling glibc fmod() as shown in the disassembly in Comment 0. > If I use the "fprem" instruction directly it gets 15x faster - but I did not > figure out some (easy) way for me how to patch GCC to no longer produce the > call to fmod() at all and produce only the "fprem" instruction. Use -ffinite-math-only option: -ffinite-math-only Allow optimizations for floating-point arithmetic that assume that arguments and results are not NaNs or +-Infs.