From d7e8898bdd83abf38faaee110805b36ff259c5f6 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Fri, 1 Jul 2016 00:37:01 +0000 Subject: LoadStoreVectorizer: if one element of a vector is integer, default to integer. Fixes issues on some architectures where we use arithmetic ops to build vectors, which can cause bad things to happen for loads/stores of mixed types. Patch by Fiona Glaser llvm-svn: 274307 --- .../lib/Transforms/Vectorize/LoadStoreVectorizer.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 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 ceadb8d0634..e0438b037c0 100644 --- a/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp +++ b/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp @@ -579,7 +579,15 @@ bool Vectorizer::vectorizeInstructions(ArrayRef Instrs) { bool Vectorizer::vectorizeStoreChain(ArrayRef Chain) { StoreInst *S0 = cast(Chain[0]); - Type *StoreTy = S0->getValueOperand()->getType(); + + // If the vector has an int element, default to int for the whole load. + Type *StoreTy; + for (const auto &V : Chain) { + StoreTy = cast(V)->getValueOperand()->getType(); + if (StoreTy->isIntOrIntVectorTy()) + break; + } + unsigned Sz = DL.getTypeSizeInBits(StoreTy); unsigned VF = VecRegSize / Sz; unsigned ChainSize = Chain.size(); @@ -700,7 +708,15 @@ bool Vectorizer::vectorizeStoreChain(ArrayRef Chain) { bool Vectorizer::vectorizeLoadChain(ArrayRef Chain) { LoadInst *L0 = cast(Chain[0]); - Type *LoadTy = L0->getType(); + + // If the vector has an int element, default to int for the whole load. + Type *LoadTy; + for (const auto &V : Chain) { + LoadTy = cast(V)->getType(); + if (LoadTy->isIntOrIntVectorTy()) + break; + } + unsigned Sz = DL.getTypeSizeInBits(LoadTy); unsigned VF = VecRegSize / Sz; unsigned ChainSize = Chain.size(); -- cgit v1.2.3