diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-09-08 00:13:52 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-09-08 00:13:52 +0000 |
| commit | 0cdbc7a2ca4cc45817790790be15d78e2bf27310 (patch) | |
| tree | 6c1dcfd6a4d4541afef8c275a1e237b9ce91cee6 /llvm/lib/Analysis/ValueTracking.cpp | |
| parent | 4bc2825d0b67b15ae1421153fb22de0a9d959b9a (diff) | |
| download | bcm5719-llvm-0cdbc7a2ca4cc45817790790be15d78e2bf27310.tar.gz bcm5719-llvm-0cdbc7a2ca4cc45817790790be15d78e2bf27310.zip | |
fix ComputeMaskedBits handling of zext/sext/trunc to work with vectors.
This fixes PR4905
llvm-svn: 81174
Diffstat (limited to 'llvm/lib/Analysis/ValueTracking.cpp')
| -rw-r--r-- | llvm/lib/Analysis/ValueTracking.cpp | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp index 78bb3dbc65d..1782edee7bf 100644 --- a/llvm/lib/Analysis/ValueTracking.cpp +++ b/llvm/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<PointerType>(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<IntegerType>(I->getOperand(0)->getType()); - unsigned SrcBitWidth = SrcTy->getBitWidth(); + unsigned SrcBitWidth = I->getOperand(0)->getType()->getScalarSizeInBits(); APInt MaskIn(Mask); MaskIn.trunc(SrcBitWidth); |

