https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121570
Thomas Koenig <tkoenig at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |tkoenig at gcc dot gnu.org Status|UNCONFIRMED |NEW Keywords| |missed-optimization Severity|normal |enhancement Last reconfirmed| |2025-08-17 Ever confirmed|0 |1 --- Comment #3 from Thomas Koenig <tkoenig at gcc dot gnu.org> --- Looking at https://godbolt.org/z/x3d8q4Krd , ifx is translating the loop in the shortened code program main !..use and access use iso_fortran_env, only : int32, real32, real64 use ieee_arithmetic implicit none !..data integer (kind=int32) :: i32, j32 real (kind=real32) :: t32, r32 real (kind=real64) :: tim0, tim1 !..executable part j32 = huge(0_int32) i32 = -j32-1 r32 = 0 call cpu_time(tim0) do while (r32.ne.t32) r32 = ieee_next_after(r32,t32) end do call cpu_time (tim1) write (*,'(a25,1pg9.2,1pg16.9)') & '2^32 ieee_next_after:', tim1-tim0, r32 stop end program main into movq %rbx, %rdi movq %r14, %rsi callq __for_ieee_next_after_k4_@PLT movss %xmm0, 12(%rsp) ucomiss 16(%rsp), %xmm0 jne .LBB0_1 jp .LBB0_1 whereas gfortran does movq %rbx, %rdi movss %xmm0, 8(%rsp) call _gfortran_ieee_procedure_entry movss 8(%rsp), %xmm0 pxor %xmm1, %xmm1 movss %xmm1, 12(%rsp) call nextafterf movq %rbx, %rdi movss %xmm0, 20(%rsp) movss %xmm0, 8(%rsp) call _gfortran_ieee_procedure_exit movss 8(%rsp), %xmm0 ucomiss 12(%rsp), %xmm0 I cannot look at what ifx's __for_ieee_next_after_k4_ does, but a separate, more optimized implementation for ieee_next_after might be faster also for gfortran. For example, it could check its argument if the operation will raise an exception, and branch in that event (which could be marked as unlikely, and after a few iterations, would be marked as unlikely to be taken by the CPU). Confirmed as an enhancement request.