mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Fix a bug in the vectorization of wide load/store operations.
We used a SCEV to detect that A[X] is consecutive. We assumed that X was the induction variable. But X can be any expression that uses the induction for example: X = i + 2; git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166388 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -740,10 +740,15 @@ SingleBlockLoopVectorizer::vectorizeLoop(LoopVectorizationLegality *Legal) {
|
||||
break;
|
||||
}
|
||||
|
||||
// The last index does not have to be the induction. It can be
|
||||
// consecutive and be a function of the index. For example A[I+1];
|
||||
unsigned NumOperands = Gep->getNumOperands();
|
||||
Value *LastIndex = getVectorValue(Gep->getOperand(NumOperands -1));
|
||||
LastIndex = Builder.CreateExtractElement(LastIndex, Builder.getInt32(0));
|
||||
|
||||
// Create the new GEP with the new induction variable.
|
||||
GetElementPtrInst *Gep2 = cast<GetElementPtrInst>(Gep->clone());
|
||||
unsigned NumOperands = Gep->getNumOperands();
|
||||
Gep2->setOperand(NumOperands - 1, Induction);
|
||||
Gep2->setOperand(NumOperands - 1, LastIndex);
|
||||
Ptr = Builder.Insert(Gep2);
|
||||
Ptr = Builder.CreateBitCast(Ptr, StTy->getPointerTo());
|
||||
Value *Val = getVectorValue(SI->getValueOperand());
|
||||
@ -764,10 +769,15 @@ SingleBlockLoopVectorizer::vectorizeLoop(LoopVectorizationLegality *Legal) {
|
||||
break;
|
||||
}
|
||||
|
||||
// The last index does not have to be the induction. It can be
|
||||
// consecutive and be a function of the index. For example A[I+1];
|
||||
unsigned NumOperands = Gep->getNumOperands();
|
||||
Value *LastIndex = getVectorValue(Gep->getOperand(NumOperands -1));
|
||||
LastIndex = Builder.CreateExtractElement(LastIndex, Builder.getInt32(0));
|
||||
|
||||
// Create the new GEP with the new induction variable.
|
||||
GetElementPtrInst *Gep2 = cast<GetElementPtrInst>(Gep->clone());
|
||||
unsigned NumOperands = Gep->getNumOperands();
|
||||
Gep2->setOperand(NumOperands - 1, Induction);
|
||||
Gep2->setOperand(NumOperands - 1, LastIndex);
|
||||
Ptr = Builder.Insert(Gep2);
|
||||
Ptr = Builder.CreateBitCast(Ptr, RetTy->getPointerTo());
|
||||
LI = Builder.CreateLoad(Ptr);
|
||||
|
Reference in New Issue
Block a user