[LoadStoreVectorizer] vectorizeStoreChain - ensure we find a store type.

Properly initialize store type to null then ensure we find a real store type in the chain.

Fixes scan-build null dereference warning and makes the code clearer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360031 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Simon Pilgrim 2019-05-06 10:25:11 +00:00
parent 4ca52ef5db
commit 0fc49e75a4

View File

@ -926,7 +926,7 @@ bool Vectorizer::vectorizeStoreChain(
StoreInst *S0 = cast<StoreInst>(Chain[0]);
// If the vector has an int element, default to int for the whole store.
Type *StoreTy;
Type *StoreTy = nullptr;
for (Instruction *I : Chain) {
StoreTy = cast<StoreInst>(I)->getValueOperand()->getType();
if (StoreTy->isIntOrIntVectorTy())
@ -938,6 +938,7 @@ bool Vectorizer::vectorizeStoreChain(
break;
}
}
assert(StoreTy && "Failed to find store type");
unsigned Sz = DL.getTypeSizeInBits(StoreTy);
unsigned AS = S0->getPointerAddressSpace();