summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
diff options
context:
space:
mode:
authorMatt Arsenault <Matthew.Arsenault@amd.com>2016-07-01 00:37:01 +0000
committerMatt Arsenault <Matthew.Arsenault@amd.com>2016-07-01 00:37:01 +0000
commitd7e8898bdd83abf38faaee110805b36ff259c5f6 (patch)
tree20e45f31bf0fba622de8e1751c0c4de97601da7b /llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
parent8a4ab5e19f948708f190223ed49add4897cc7833 (diff)
downloadbcm5719-llvm-d7e8898bdd83abf38faaee110805b36ff259c5f6.tar.gz
bcm5719-llvm-d7e8898bdd83abf38faaee110805b36ff259c5f6.zip
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
Diffstat (limited to 'llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp')
-rw-r--r--llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp20
1 files changed, 18 insertions, 2 deletions
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<Value *> Instrs) {
bool Vectorizer::vectorizeStoreChain(ArrayRef<Value *> Chain) {
StoreInst *S0 = cast<StoreInst>(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<StoreInst>(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<Value *> Chain) {
bool Vectorizer::vectorizeLoadChain(ArrayRef<Value *> Chain) {
LoadInst *L0 = cast<LoadInst>(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<LoadInst>(V)->getType();
+ if (LoadTy->isIntOrIntVectorTy())
+ break;
+ }
+
unsigned Sz = DL.getTypeSizeInBits(LoadTy);
unsigned VF = VecRegSize / Sz;
unsigned ChainSize = Chain.size();
OpenPOWER on IntegriCloud