Fix PR14547. Handle induction variables of small sizes smaller than i32 (i8 and i16).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172348 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Nadav Rotem
2013-01-13 07:56:29 +00:00
parent 981308cffb
commit b6db95f42b
2 changed files with 38 additions and 0 deletions

View File

@ -1033,11 +1033,14 @@ InnerLoopVectorizer::createEmptyLoop(LoopVectorizationLegality *Legal) {
// We may need to extend the index in case there is a type mismatch.
// We know that the count starts at zero and does not overflow.
unsigned IdxTyBW = IdxTy->getScalarSizeInBits();
if (Count->getType() != IdxTy) {
// The exit count can be of pointer type. Convert it to the correct
// integer type.
if (ExitCount->getType()->isPointerTy())
Count = CastInst::CreatePointerCast(Count, IdxTy, "ptrcnt.to.int", Loc);
else if (IdxTyBW < Count->getType()->getScalarSizeInBits())
Count = CastInst::CreateTruncOrBitCast(Count, IdxTy, "tr.cnt", Loc);
else
Count = CastInst::CreateZExtOrBitCast(Count, IdxTy, "zext.cnt", Loc);
}