From 7302d80490feabfc8a01bee0fa698aab55169544 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 6 Feb 2012 21:56:39 +0000 Subject: Remove some dead code and tidy things up now that vectors use ConstantDataVector instead of always using ConstantVector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@149912 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ConstantFolding.cpp | 32 ++++++++++++++------------------ lib/Analysis/ValueTracking.cpp | 15 ++------------- 2 files changed, 16 insertions(+), 31 deletions(-) (limited to 'lib/Analysis') diff --git a/lib/Analysis/ConstantFolding.cpp b/lib/Analysis/ConstantFolding.cpp index 48e75a1..6e2a8d4 100644 --- a/lib/Analysis/ConstantFolding.cpp +++ b/lib/Analysis/ConstantFolding.cpp @@ -54,37 +54,35 @@ static Constant *FoldBitCast(Constant *C, Type *DestTy, // Handle a vector->integer cast. if (IntegerType *IT = dyn_cast(DestTy)) { - // FIXME: Remove ConstantVector support. - if ((!isa(C) && !isa(C)) || - // TODO: Handle big endian someday. - !TD.isLittleEndian()) + ConstantDataVector *CDV = dyn_cast(C); + if (CDV == 0) return ConstantExpr::getBitCast(C, DestTy); - unsigned NumSrcElts = C->getType()->getVectorNumElements(); + unsigned NumSrcElts = CDV->getType()->getNumElements(); + + Type *SrcEltTy = CDV->getType()->getElementType(); // If the vector is a vector of floating point, convert it to vector of int // to simplify things. - if (C->getType()->getVectorElementType()->isFloatingPointTy()) { - unsigned FPWidth = - C->getType()->getVectorElementType()->getPrimitiveSizeInBits(); + if (SrcEltTy->isFloatingPointTy()) { + unsigned FPWidth = SrcEltTy->getPrimitiveSizeInBits(); Type *SrcIVTy = VectorType::get(IntegerType::get(C->getContext(), FPWidth), NumSrcElts); // Ask VMCore to do the conversion now that #elts line up. C = ConstantExpr::getBitCast(C, SrcIVTy); + CDV = cast(C); } // Now that we know that the input value is a vector of integers, just shift // and insert them into our result. - unsigned BitShift = - TD.getTypeAllocSizeInBits(C->getType()->getVectorElementType()); + unsigned BitShift = TD.getTypeAllocSizeInBits(SrcEltTy); APInt Result(IT->getBitWidth(), 0); for (unsigned i = 0; i != NumSrcElts; ++i) { - // FIXME: Rework when we have ConstantDataVector. - ConstantInt *Elt=dyn_cast_or_null(C->getAggregateElement(i)); - if (Elt == 0) // Elt must be a constant expr or something. - return ConstantExpr::getBitCast(C, DestTy); - - Result |= Elt->getValue().zextOrSelf(IT->getBitWidth()) << i*BitShift; + Result <<= BitShift; + if (TD.isLittleEndian()) + Result |= CDV->getElementAsInteger(NumSrcElts-i-1); + else + Result |= CDV->getElementAsInteger(i); } return ConstantInt::get(IT, Result); @@ -103,7 +101,6 @@ static Constant *FoldBitCast(Constant *C, Type *DestTy, } // If this is a bitcast from constant vector -> vector, fold it. - // FIXME: Remove ConstantVector support. if (!isa(C) && !isa(C)) return ConstantExpr::getBitCast(C, DestTy); @@ -350,7 +347,6 @@ static bool ReadDataFromGlobal(Constant *C, uint64_t ByteOffset, // not reached. } - // FIXME: Remove ConstantVector if (isa(C) || isa(C) || isa(C)) { Type *EltTy = cast(C->getType())->getElementType(); diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 1a18247..b5811f2 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -88,19 +88,8 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask, return; } // Handle a constant vector by taking the intersection of the known bits of - // each element. - // FIXME: Remove. - if (ConstantVector *CV = dyn_cast(V)) { - KnownZero.setAllBits(); KnownOne.setAllBits(); - for (unsigned i = 0, e = CV->getNumOperands(); i != e; ++i) { - APInt KnownZero2(BitWidth, 0), KnownOne2(BitWidth, 0); - ComputeMaskedBits(CV->getOperand(i), Mask, KnownZero2, KnownOne2, - TD, Depth); - KnownZero &= KnownZero2; - KnownOne &= KnownOne2; - } - return; - } + // each element. There is no real need to handle ConstantVector here, because + // we don't handle undef in any particularly useful way. if (ConstantDataSequential *CDS = dyn_cast(V)) { // We know that CDS must be a vector of integers. Take the intersection of // each element. -- cgit v1.1