mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-01 12:24:24 +00:00
remove constant terms
The delinearization is needed only to remove the non linearity induced by expressions involving multiplications of parameters and induction variables. There is no problem in dealing with constant times parameters, or constant times an induction variable. For this reason, the current patch discards all constant terms and multipliers before running the delinearization algorithm on the terms. The only thing remaining in the term expressions are parameters and multiply expressions of parameters: these simplified term expressions are passed to the array shape recognizer that will not recognize constant dimensions anymore: these will be recognized as different strides in parametric subscripts. The only important special case of a constant dimension is the size of elements. Instead of relying on the delinearization to infer the size of an element, compute the element size from the base address type. This is a much more precise way of computing the element size than before, as we would have mixed together the size of an element with the strides of the innermost dimension. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209691 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -3180,9 +3180,10 @@ void DependenceAnalysis::updateDirection(Dependence::DVEntry &Level,
|
||||
/// source and destination array references are recurrences on a nested loop,
|
||||
/// this function flattens the nested recurrences into separate recurrences
|
||||
/// for each loop level.
|
||||
bool
|
||||
DependenceAnalysis::tryDelinearize(const SCEV *SrcSCEV, const SCEV *DstSCEV,
|
||||
SmallVectorImpl<Subscript> &Pair) const {
|
||||
bool DependenceAnalysis::tryDelinearize(const SCEV *SrcSCEV,
|
||||
const SCEV *DstSCEV,
|
||||
SmallVectorImpl<Subscript> &Pair,
|
||||
const SCEV *ElementSize) const {
|
||||
const SCEVAddRecExpr *SrcAR = dyn_cast<SCEVAddRecExpr>(SrcSCEV);
|
||||
const SCEVAddRecExpr *DstAR = dyn_cast<SCEVAddRecExpr>(DstSCEV);
|
||||
if (!SrcAR || !DstAR || !SrcAR->isAffine() || !DstAR->isAffine())
|
||||
@ -3195,7 +3196,7 @@ DependenceAnalysis::tryDelinearize(const SCEV *SrcSCEV, const SCEV *DstSCEV,
|
||||
|
||||
// Second step: find subscript sizes.
|
||||
SmallVector<const SCEV *, 4> Sizes;
|
||||
SE->findArrayDimensions(Terms, Sizes);
|
||||
SE->findArrayDimensions(Terms, Sizes, ElementSize);
|
||||
|
||||
// Third step: compute the access functions for each subscript.
|
||||
SmallVector<const SCEV *, 4> SrcSubscripts, DstSubscripts;
|
||||
@ -3353,7 +3354,7 @@ Dependence *DependenceAnalysis::depends(Instruction *Src,
|
||||
}
|
||||
|
||||
if (Delinearize && Pairs == 1 && CommonLevels > 1 &&
|
||||
tryDelinearize(Pair[0].Src, Pair[0].Dst, Pair)) {
|
||||
tryDelinearize(Pair[0].Src, Pair[0].Dst, Pair, SE->getElementSize(Src))) {
|
||||
DEBUG(dbgs() << " delinerized GEP\n");
|
||||
Pairs = Pair.size();
|
||||
}
|
||||
@ -3777,7 +3778,7 @@ const SCEV *DependenceAnalysis::getSplitIteration(const Dependence *Dep,
|
||||
}
|
||||
|
||||
if (Delinearize && Pairs == 1 && CommonLevels > 1 &&
|
||||
tryDelinearize(Pair[0].Src, Pair[0].Dst, Pair)) {
|
||||
tryDelinearize(Pair[0].Src, Pair[0].Dst, Pair, SE->getElementSize(Src))) {
|
||||
DEBUG(dbgs() << " delinerized GEP\n");
|
||||
Pairs = Pair.size();
|
||||
}
|
||||
|
Reference in New Issue
Block a user