[llvm-commits] [llvm] r122613 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp unittests/VMCore/ConstantsTest.cpp
Chris Lattner
sabre at nondot.org
Tue Dec 28 17:33:36 PST 2010
Author: lattner
Date: Tue Dec 28 19:33:36 2010
New Revision: 122613
URL: http://llvm.org/viewvc/llvm-project?rev=122613&view=rev
Log:
fix PR8867: a crash handling fp128. Thanks to Nick for the testcase.
Modified:
llvm/trunk/lib/VMCore/ConstantFold.cpp
llvm/trunk/unittests/VMCore/ConstantsTest.cpp
Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=122613&r1=122612&r2=122613&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Tue Dec 28 19:33:36 2010
@@ -637,7 +637,7 @@
case Instruction::SIToFP:
if (ConstantInt *CI = dyn_cast<ConstantInt>(V)) {
APInt api = CI->getValue();
- APFloat apf(APInt::getNullValue(DestTy->getPrimitiveSizeInBits()));
+ APFloat apf(APInt::getNullValue(DestTy->getPrimitiveSizeInBits()), true);
(void)apf.convertFromAPInt(api,
opc==Instruction::SIToFP,
APFloat::rmNearestTiesToEven);
Modified: llvm/trunk/unittests/VMCore/ConstantsTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/VMCore/ConstantsTest.cpp?rev=122613&r1=122612&r2=122613&view=diff
==============================================================================
--- llvm/trunk/unittests/VMCore/ConstantsTest.cpp (original)
+++ llvm/trunk/unittests/VMCore/ConstantsTest.cpp Tue Dec 28 19:33:36 2010
@@ -109,5 +109,14 @@
EXPECT_EQ(0x3b, ConstantInt::get(Int8Ty, 0x13b)->getSExtValue());
}
+TEST(ConstantsTest, FP128Test) {
+ const Type *FP128Ty = Type::getFP128Ty(getGlobalContext());
+
+ const IntegerType *Int128Ty = Type::getIntNTy(getGlobalContext(), 128);
+ Constant *Zero128 = Constant::getNullValue(Int128Ty);
+ Constant *X = ConstantExpr::getUIToFP(Zero128, FP128Ty);
+ EXPECT_TRUE(isa<ConstantFP>(X));
+}
+
} // end anonymous namespace
} // end namespace llvm
More information about the llvm-commits
mailing list