[flang-commits] [flang] [flang] Use llvm.llround for an INTEGER(8) NINT result (PR #224580)

via flang-commits flang-commits at lists.llvm.org
Fri Sep 18 02:47:04 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-fir-hlfir

Author: Martin Schlipf (martin-schlipf)

<details>
<summary>Changes</summary>

NINT with an INTEGER(8) result lowered to llvm.lround, which lowers to a call to lround. lround returns a C long, so it is only 64 bits wide on an LP64 target. On an ILP32 target the call returns 32 bits where an i64 is expected: on i386 the result is silently truncated, and the WebAssembly backend emits an invalid module ("local.set's value type must be correct") rather than diagnosing the mismatch.

llround returns a long long and is therefore 64 bits everywhere. The REAL(16) row of the same table already uses LlroundF128 for its INTEGER(8) result, so this makes the REAL(4) and REAL(8) rows consistent with it.

The INTEGER(4) rows keep llvm.lround, which is correct: a C int and a C long are both at least 32 bits on every supported target.

---
Full diff: https://github.com/llvm/llvm-project/pull/224580.diff


3 Files Affected:

- (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+5-2) 
- (modified) flang/test/Lower/Intrinsics/nint.f90 (+10-1) 
- (modified) flang/test/Lower/math-lowering/nint.f90 (+4-4) 


``````````diff
The server is unavailable at this time. Please wait a few minutes before you try again.
``````````

</details>


https://github.com/llvm/llvm-project/pull/224580


More information about the flang-commits mailing list