[llvm] [NVPTX] fixup incorrect rounding mode for int to float conversion (PR #106600)

Thomas Raoux via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 29 11:17:19 PDT 2024


================
@@ -290,15 +290,16 @@ static Instruction *simplifyNvvmIntrinsic(IntrinsicInst *II, InstCombiner &IC) {
     case Intrinsic::nvvm_d2ull_rz:
     case Intrinsic::nvvm_f2ull_rz:
       return {Instruction::FPToUI};
-    case Intrinsic::nvvm_i2d_rz:
-    case Intrinsic::nvvm_i2f_rz:
-    case Intrinsic::nvvm_ll2d_rz:
-    case Intrinsic::nvvm_ll2f_rz:
+    // Integer to floating-point uses RN rounding, not RZ
+    case Intrinsic::nvvm_i2d_rn:
----------------
ThomasRaoux wrote:

according to [LLVM IR spec](https://llvm.org/docs/LangRef.html#fptoui-to-instruction) fptoui should be rounding toward zero:
```
The ‘fptoui’ instruction converts its [floating-point](https://llvm.org/docs/LangRef.html#t-floating) operand into the nearest (rounding towards zero) unsigned integer value.
```


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


More information about the llvm-commits mailing list