diff options
author | Duncan Sands <baldrick@free.fr> | 2012-11-13 12:59:33 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2012-11-13 12:59:33 +0000 |
commit | 2333e29be441d9d55920651e0b2add23ab0c1613 (patch) | |
tree | a81026fd460acee57a8305816fea3c2a75879aee /lib/VMCore/Verifier.cpp | |
parent | 563e8fce2ee22b21beb40ac65a6eaf2199d30414 (diff) | |
download | external_llvm-2333e29be441d9d55920651e0b2add23ab0c1613.tar.gz external_llvm-2333e29be441d9d55920651e0b2add23ab0c1613.tar.bz2 external_llvm-2333e29be441d9d55920651e0b2add23ab0c1613.zip |
Relax the restrictions on vector of pointer types, and vector getelementptr.
Previously in a vector of pointers, the pointer couldn't be any pointer type,
it had to be a pointer to an integer or floating point type. This is a hassle
for dragonegg because the GCC vectorizer happily produces vectors of pointers
where the pointer is a pointer to a struct or whatever. Vector getelementptr
was restricted to just one index, but now that vectors of pointers can have
any pointer type it is more natural to allow arbitrary vector getelementptrs.
There is however the issue of struct GEPs, where if each lane chose different
struct fields then from that point on each lane will be working down into
unrelated types. This seems like too much pain for too little gain, so when
you have a vector struct index all the elements are required to be the same.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167828 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r-- | lib/VMCore/Verifier.cpp | 41 |
1 files changed, 19 insertions, 22 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index eb40b09d29..3782957f3b 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -1375,34 +1375,31 @@ void Verifier::visitGetElementPtrInst(GetElementPtrInst &GEP) { "GEP base pointer is not a vector or a vector of pointers", &GEP); Assert1(cast<PointerType>(TargetTy)->getElementType()->isSized(), "GEP into unsized type!", &GEP); + Assert1(GEP.getPointerOperandType()->isVectorTy() == + GEP.getType()->isVectorTy(), "Vector GEP must return a vector value", + &GEP); SmallVector<Value*, 16> Idxs(GEP.idx_begin(), GEP.idx_end()); Type *ElTy = GetElementPtrInst::getIndexedType(GEP.getPointerOperandType(), Idxs); Assert1(ElTy, "Invalid indices for GEP pointer type!", &GEP); - if (GEP.getPointerOperandType()->isPointerTy()) { - // Validate GEPs with scalar indices. - Assert2(GEP.getType()->isPointerTy() && - cast<PointerType>(GEP.getType())->getElementType() == ElTy, - "GEP is not of right type for indices!", &GEP, ElTy); - } else { - // Validate GEPs with a vector index. - Assert1(Idxs.size() == 1, "Invalid number of indices!", &GEP); - Value *Index = Idxs[0]; - Type *IndexTy = Index->getType(); - Assert1(IndexTy->isVectorTy(), - "Vector GEP must have vector indices!", &GEP); - Assert1(GEP.getType()->isVectorTy(), - "Vector GEP must return a vector value", &GEP); - Type *ElemPtr = cast<VectorType>(GEP.getType())->getElementType(); - Assert1(ElemPtr->isPointerTy(), - "Vector GEP pointer operand is not a pointer!", &GEP); - unsigned IndexWidth = cast<VectorType>(IndexTy)->getNumElements(); - unsigned GepWidth = cast<VectorType>(GEP.getType())->getNumElements(); - Assert1(IndexWidth == GepWidth, "Invalid GEP index vector width", &GEP); - Assert1(ElTy == cast<PointerType>(ElemPtr)->getElementType(), - "Vector GEP type does not match pointer type!", &GEP); + Assert2(GEP.getType()->getScalarType()->isPointerTy() && + cast<PointerType>(GEP.getType()->getScalarType())->getElementType() + == ElTy, "GEP is not of right type for indices!", &GEP, ElTy); + + if (GEP.getPointerOperandType()->isVectorTy()) { + // Additional checks for vector GEPs. + unsigned GepWidth = GEP.getPointerOperandType()->getVectorNumElements(); + Assert1(GepWidth == GEP.getType()->getVectorNumElements(), + "Vector GEP result width doesn't match operand's", &GEP); + for (unsigned i = 0, e = Idxs.size(); i != e; ++i) { + Type *IndexTy = Idxs[i]->getType(); + Assert1(IndexTy->isVectorTy(), + "Vector GEP must have vector indices!", &GEP); + unsigned IndexWidth = IndexTy->getVectorNumElements(); + Assert1(IndexWidth == GepWidth, "Invalid GEP index vector width", &GEP); + } } visitInstruction(GEP); } |