[llvm] [Float2Int] Fix miscompile with floats that can be converted to large values (PR #85996)

via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 20 12:58:00 PDT 2024


================
@@ -409,7 +409,8 @@ Value *Float2IntPass::convert(Instruction *I, Type *ToTy) {
     } else if (Instruction *VI = dyn_cast<Instruction>(V)) {
       NewOperands.push_back(convert(VI, ToTy));
     } else if (ConstantFP *CF = dyn_cast<ConstantFP>(V)) {
-      APSInt Val(ToTy->getPrimitiveSizeInBits(), /*isUnsigned=*/false);
+      APSInt Val(ToTy->getPrimitiveSizeInBits(),
+                 !CF->getValueAPF().isNegative());
----------------
AtariDreams wrote:

But even then, I thought INT_MIN was exempted from consideration

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


More information about the llvm-commits mailing list