NVFORTRAN 26.5 generates invalid LLVM IR with -Ktrap for REAL(SHIFTR(...))

Hello,

NVFORTRAN 26.5 aborts while compiling the following standard-conforming Fortran 2008 program whenever a -Ktrap option is specified, including -Ktrap=none.

I previously reproduced the same failure with NVFORTRAN 26.3.

Environment

nvfortran 26.5-0 64-bit target on x86-64 Linux -tp cascadelake
NVIDIA Compilers and Tools
Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.

Minimal reproducer

Save as reproducer.f90:

subroutine convert(words, values)
use iso_fortran_env, only: int64, real64
implicit none

integer(int64), intent(in) :: words
real(real64), intent(out) :: values

values = real(shiftr(words, 8), real64) / 256.0_real64
end subroutine convert

Compile with:

nvfortran -O0 -Ktrap=fp -c reproducer.f90

The compiler exits with status 2:

Intrinsic has incorrect argument type!
ptr @llvm.experimental.constrained.fdiv.f64
LLVM ERROR: Broken module found, compilation aborted!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
...
nvfortran-Fatal-/home/pedro/software/nvidia/hpc_sdk/Linux_x86_64/26.5/compilers/share/llvm/bin/llc TERMINATED by signal 6

The same failure and exit status occur with:

nvfortran -O0 -Ktrap=none -c reproducer.f90

In contrast, omitting -Ktrap succeeds with exit status 0:

nvfortran -O0 -c reproducer.f90

Thus, even -Ktrap=none activates a code-generation path that produces an invalid declaration or call of llvm.experimental.constrained.fdiv.f64.

Workaround

Materializing the result of SHIFTR before converting it to REAL avoids the failure:

subroutine convert(words, values)
use iso_fortran_env, only: int64, real64
implicit none

integer(int64), intent(in) :: words
real(real64), intent(out) :: values
integer(int64) :: shifted

shifted = shiftr(words, 8)
values = real(shifted, real64) / 256.0_real64
end subroutine convert

This version compiles successfully with exit status 0:

nvfortran -O0 -Ktrap=fp -c workaround.f90

Thanks in advance for looking into this!

Thanks for the report Pedro and the nice reproducer!

Looks to be a new code generation issue as of the 25.9 release. I added a report, TPR #38904, and sent to engineering for investigation.

-Mat

Hi! I’d like to notify you that this issue is now resolved with the release of 26.9! Thank you very much for letting us know! If you find any issues in the future, please feel free to reach back out.

Awesome! Thanks for letting me know.