mirror of
https://github.com/RPCS3/llvm.git
synced 2026-08-25 11:51:41 -04:00
Skip bitcasts while looking for GEP in LoadStoreVectorizer
Differential Revisison: https://reviews.llvm.org/D32101 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301343 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -65,7 +65,9 @@ public:
|
||||
bool run();
|
||||
|
||||
private:
|
||||
Value *getPointerOperand(Value *I);
|
||||
Value *getPointerOperand(Value *I) const;
|
||||
|
||||
GetElementPtrInst *getSourceGEP(Value *Src) const;
|
||||
|
||||
unsigned getPointerAddressSpace(Value *I);
|
||||
|
||||
@@ -215,7 +217,7 @@ bool Vectorizer::run() {
|
||||
return Changed;
|
||||
}
|
||||
|
||||
Value *Vectorizer::getPointerOperand(Value *I) {
|
||||
Value *Vectorizer::getPointerOperand(Value *I) const {
|
||||
if (LoadInst *LI = dyn_cast<LoadInst>(I))
|
||||
return LI->getPointerOperand();
|
||||
if (StoreInst *SI = dyn_cast<StoreInst>(I))
|
||||
@@ -231,6 +233,19 @@ unsigned Vectorizer::getPointerAddressSpace(Value *I) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
GetElementPtrInst *Vectorizer::getSourceGEP(Value *Src) const {
|
||||
// First strip pointer bitcasts. Make sure pointee size is the same with
|
||||
// and without casts.
|
||||
// TODO: a stride set by the add instruction below can match the difference
|
||||
// in pointee type size here. Currently it will not be vectorized.
|
||||
Value *SrcPtr = getPointerOperand(Src);
|
||||
Value *SrcBase = SrcPtr->stripPointerCasts();
|
||||
if (DL.getTypeStoreSize(SrcPtr->getType()->getPointerElementType()) ==
|
||||
DL.getTypeStoreSize(SrcBase->getType()->getPointerElementType()))
|
||||
SrcPtr = SrcBase;
|
||||
return dyn_cast<GetElementPtrInst>(SrcPtr);
|
||||
}
|
||||
|
||||
// FIXME: Merge with llvm::isConsecutiveAccess
|
||||
bool Vectorizer::isConsecutiveAccess(Value *A, Value *B) {
|
||||
Value *PtrA = getPointerOperand(A);
|
||||
@@ -283,8 +298,8 @@ bool Vectorizer::isConsecutiveAccess(Value *A, Value *B) {
|
||||
|
||||
// Look through GEPs after checking they're the same except for the last
|
||||
// index.
|
||||
GetElementPtrInst *GEPA = dyn_cast<GetElementPtrInst>(getPointerOperand(A));
|
||||
GetElementPtrInst *GEPB = dyn_cast<GetElementPtrInst>(getPointerOperand(B));
|
||||
GetElementPtrInst *GEPA = getSourceGEP(A);
|
||||
GetElementPtrInst *GEPB = getSourceGEP(B);
|
||||
if (!GEPA || !GEPB || GEPA->getNumOperands() != GEPB->getNumOperands())
|
||||
return false;
|
||||
unsigned FinalIndex = GEPA->getNumOperands() - 1;
|
||||
|
||||
Reference in New Issue
Block a user