aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/ConstantFold.cpp
diff options
context:
space:
mode:
authorDale Johannesen <dalej@apple.com>2007-09-12 03:30:33 +0000
committerDale Johannesen <dalej@apple.com>2007-09-12 03:30:33 +0000
commitfbd9cdafa9a1e124a0866470dc1d8f514d5db30e (patch)
treeda064f263b6242adf84ced2a98439707a6114ddd /lib/VMCore/ConstantFold.cpp
parentf5febb9ef86c5f67872301153137d3cf7db1c62f (diff)
downloadexternal_llvm-fbd9cdafa9a1e124a0866470dc1d8f514d5db30e.tar.gz
external_llvm-fbd9cdafa9a1e124a0866470dc1d8f514d5db30e.tar.bz2
external_llvm-fbd9cdafa9a1e124a0866470dc1d8f514d5db30e.zip
Revise previous patch per review comments.
Next round of x87 long double stuff. Getting close now, basically works. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41875 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/ConstantFold.cpp')
-rw-r--r--lib/VMCore/ConstantFold.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/VMCore/ConstantFold.cpp b/lib/VMCore/ConstantFold.cpp
index e11b749f9b..5c80a377ba 100644
--- a/lib/VMCore/ConstantFold.cpp
+++ b/lib/VMCore/ConstantFold.cpp
@@ -87,8 +87,8 @@ static Constant *CastConstantVector(ConstantVector *CV,
if (SrcEltTy->getTypeID() == Type::DoubleTyID) {
for (unsigned i = 0; i != SrcNumElts; ++i) {
- uint64_t V = *cast<ConstantFP>(CV->getOperand(i))->
- getValueAPF().convertToAPInt().getRawData();
+ uint64_t V = cast<ConstantFP>(CV->getOperand(i))->
+ getValueAPF().convertToAPInt().getZExtValue();
Constant *C = ConstantInt::get(Type::Int64Ty, V);
Result.push_back(ConstantExpr::getBitCast(C, DstEltTy ));
}
@@ -97,8 +97,8 @@ static Constant *CastConstantVector(ConstantVector *CV,
assert(SrcEltTy->getTypeID() == Type::FloatTyID);
for (unsigned i = 0; i != SrcNumElts; ++i) {
- uint32_t V = (uint32_t)*cast<ConstantFP>(CV->getOperand(i))->
- getValueAPF().convertToAPInt().getRawData();
+ uint32_t V = (uint32_t)cast<ConstantFP>(CV->getOperand(i))->
+ getValueAPF().convertToAPInt().getZExtValue();
Constant *C = ConstantInt::get(Type::Int32Ty, V);
Result.push_back(ConstantExpr::getBitCast(C, DstEltTy));
}
@@ -331,9 +331,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
return const_cast<Constant*>(V);
if (DestTy->isFloatingPoint()) {
- if (DestTy == Type::FloatTy)
- return ConstantFP::get(DestTy, APFloat(CI->getValue()));
- assert(DestTy == Type::DoubleTy && "Unknown FP type!");
+ assert((DestTy == Type::DoubleTy || DestTy == Type::FloatTy) &&
+ "Unknown FP type!");
return ConstantFP::get(DestTy, APFloat(CI->getValue()));
}
// Otherwise, can't fold this (vector?)