Fix a crasher introduced by r127317 that is seen on the bots when using an

alloca as both integer and floating-point vectors of the same size. Bugpoint is
not cooperating with me, but I'll try to find a manual testcase tomorrow.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127320 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Cameron Zwarich 2011-03-09 07:34:11 +00:00
parent 84dd4fa2e3
commit 032c10fee2

View File

@ -681,12 +681,18 @@ ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType,
// access or a bitcast to another vector type of the same size.
if (const VectorType *VTy = dyn_cast<VectorType>(FromVal->getType())) {
if (ToType->isVectorTy()) {
if (isPowerOf2_64(AllocaSize / TD.getTypeAllocSize(ToType))) {
unsigned ToTypeSize = TD.getTypeAllocSize(ToType);
if (ToTypeSize == AllocaSize)
return Builder.CreateBitCast(FromVal, ToType, "tmp");
assert(isPowerOf2_64(AllocaSize / ToTypeSize) &&
"Partial vector access of an alloca must have a power-of-2 size "
"ratio.");
assert(Offset == 0 && "Can't extract a value of a smaller vector type "
"from a nonzero offset.");
const Type *ToElementTy = cast<VectorType>(ToType)->getElementType();
unsigned Scale = AllocaSize / TD.getTypeAllocSize(ToType);
unsigned Scale = AllocaSize / ToTypeSize;
const Type *CastElementTy = getScaledElementType(ToElementTy, Scale);
unsigned NumCastVectorElements = VTy->getNumElements() / Scale;
@ -699,9 +705,6 @@ ConvertScalar_ExtractValue(Value *FromVal, const Type *ToType,
return Builder.CreateBitCast(Extract, ToType, "tmp");
}
return Builder.CreateBitCast(FromVal, ToType, "tmp");
}
// Otherwise it must be an element access.
unsigned Elt = 0;
if (Offset) {