From 1698f255e9973fbc44b66852770e289db3abfa83 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 8 Sep 2009 00:13:52 +0000 Subject: fix ComputeMaskedBits handling of zext/sext/trunc to work with vectors. This fixes PR4905 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@81174 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/ValueTracking.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'lib') diff --git a/lib/Analysis/ValueTracking.cpp b/lib/Analysis/ValueTracking.cpp index 78bb3db..1782ede 100644 --- a/lib/Analysis/ValueTracking.cpp +++ b/lib/Analysis/ValueTracking.cpp @@ -232,12 +232,16 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask, // FALL THROUGH and handle them the same as zext/trunc. case Instruction::ZExt: case Instruction::Trunc: { + const Type *SrcTy = I->getOperand(0)->getType(); + + unsigned SrcBitWidth; // Note that we handle pointer operands here because of inttoptr/ptrtoint // which fall through here. - const Type *SrcTy = I->getOperand(0)->getType(); - unsigned SrcBitWidth = TD ? - TD->getTypeSizeInBits(SrcTy) : - SrcTy->getScalarSizeInBits(); + if (isa(SrcTy)) + SrcBitWidth = TD->getTypeSizeInBits(SrcTy); + else + SrcBitWidth = SrcTy->getScalarSizeInBits(); + APInt MaskIn(Mask); MaskIn.zextOrTrunc(SrcBitWidth); KnownZero.zextOrTrunc(SrcBitWidth); @@ -265,8 +269,7 @@ void llvm::ComputeMaskedBits(Value *V, const APInt &Mask, } case Instruction::SExt: { // Compute the bits in the result that are not present in the input. - const IntegerType *SrcTy = cast(I->getOperand(0)->getType()); - unsigned SrcBitWidth = SrcTy->getBitWidth(); + unsigned SrcBitWidth = I->getOperand(0)->getType()->getScalarSizeInBits(); APInt MaskIn(Mask); MaskIn.trunc(SrcBitWidth); -- cgit v1.1