mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
remove BasePointer before delinearizing
No functional change is intended: instead of relying on the delinearization to come up with the base pointer as a remainder of the divisions in the delinearization, we just compute it from the array access and use that value. We substract the base pointer from the SCEV to be delinearized and that simplifies the work of the delinearizer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209692 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -95,26 +95,34 @@ void Delinearization::print(raw_ostream &O, const Module *) const {
|
||||
// Do not analyze memory accesses outside loops.
|
||||
for (Loop *L = LI->getLoopFor(BB); L != nullptr; L = L->getParentLoop()) {
|
||||
const SCEV *AccessFn = SE->getSCEVAtScope(getPointerOperand(*Inst), L);
|
||||
|
||||
const SCEVUnknown *BasePointer =
|
||||
dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFn));
|
||||
// Do not delinearize if we cannot find the base pointer.
|
||||
if (!BasePointer)
|
||||
break;
|
||||
AccessFn = SE->getMinusSCEV(AccessFn, BasePointer);
|
||||
const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(AccessFn);
|
||||
|
||||
// Do not try to delinearize memory accesses that are not AddRecs.
|
||||
if (!AR)
|
||||
break;
|
||||
|
||||
|
||||
O << "\n";
|
||||
O << "Inst:" << *Inst << "\n";
|
||||
O << "In Loop with Header: " << L->getHeader()->getName() << "\n";
|
||||
|
||||
O << "AddRec: " << *AR << "\n";
|
||||
|
||||
SmallVector<const SCEV *, 3> Subscripts, Sizes;
|
||||
const SCEV *Res = AR->delinearize(*SE, Subscripts, Sizes, SE->getElementSize(Inst));
|
||||
AR->delinearize(*SE, Subscripts, Sizes, SE->getElementSize(Inst));
|
||||
if (Subscripts.size() == 0 || Sizes.size() == 0 ||
|
||||
Subscripts.size() != Sizes.size()) {
|
||||
O << "failed to delinearize\n";
|
||||
continue;
|
||||
}
|
||||
O << "Base offset: " << *Res << "\n";
|
||||
|
||||
O << "Base offset: " << *BasePointer << "\n";
|
||||
O << "ArrayDecl[UnknownSize]";
|
||||
int Size = Subscripts.size();
|
||||
for (int i = 0; i < Size - 1; i++)
|
||||
|
Reference in New Issue
Block a user