From 8a4ab5e19f948708f190223ed49add4897cc7833 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 1 Jul 2016 00:36:54 +0000 Subject: LoadStoreVectorizer: Fix crashes on sub-byte types llvm-svn: 274306 --- llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp') diff --git a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp index 567e8e6eb1d..ceadb8d0634 100644 --- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -437,8 +437,14 @@ void Vectorizer::collectInstructions(BasicBlock *BB) { if (!VectorType::isValidElementType(Ty->getScalarType())) continue; + // Skip weird non-byte sizes. They probably aren't worth the effort of + // handling correctly. + unsigned TySize = DL.getTypeSizeInBits(Ty); + if (TySize < 8) + continue; + // No point in looking at these if they're too big to vectorize. - if (DL.getTypeSizeInBits(Ty) > VecRegSize / 2) + if (TySize > VecRegSize / 2) continue; // Make sure all the users of a vector are constant-index extracts. @@ -464,7 +470,13 @@ void Vectorizer::collectInstructions(BasicBlock *BB) { if (!VectorType::isValidElementType(Ty->getScalarType())) continue; - if (DL.getTypeSizeInBits(Ty) > VecRegSize / 2) + // Skip weird non-byte sizes. They probably aren't worth the effort of + // handling correctly. + unsigned TySize = DL.getTypeSizeInBits(Ty); + if (TySize < 8) + continue; + + if (TySize > VecRegSize / 2) continue; if (isa(Ty) && -- cgit v1.2.3