mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-23 01:24:30 +00:00
[DependenceAnalysis] Fix for PR21585: collectUpperBound triggers asserts
collectUpperBound hits an assertion when the back edge count is wider then the desired type. If that happens, truncate the backedge count. Patch by Philip Pfaffe! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237439 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -830,6 +830,14 @@ bool DependenceAnalysis::checkSrcSubscript(const SCEV *Src,
|
||||
return isLoopInvariant(Src, LoopNest);
|
||||
const SCEV *Start = AddRec->getStart();
|
||||
const SCEV *Step = AddRec->getStepRecurrence(*SE);
|
||||
const SCEV *UB = SE->getBackedgeTakenCount(AddRec->getLoop());
|
||||
if (!isa<SCEVCouldNotCompute>(UB)) {
|
||||
if (SE->getTypeSizeInBits(Start->getType()) <
|
||||
SE->getTypeSizeInBits(UB->getType())) {
|
||||
if (!AddRec->getNoWrapFlags())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!isLoopInvariant(Step, LoopNest))
|
||||
return false;
|
||||
Loops.set(mapSrcLoop(AddRec->getLoop()));
|
||||
@ -848,6 +856,14 @@ bool DependenceAnalysis::checkDstSubscript(const SCEV *Dst,
|
||||
return isLoopInvariant(Dst, LoopNest);
|
||||
const SCEV *Start = AddRec->getStart();
|
||||
const SCEV *Step = AddRec->getStepRecurrence(*SE);
|
||||
const SCEV *UB = SE->getBackedgeTakenCount(AddRec->getLoop());
|
||||
if (!isa<SCEVCouldNotCompute>(UB)) {
|
||||
if (SE->getTypeSizeInBits(Start->getType()) <
|
||||
SE->getTypeSizeInBits(UB->getType())) {
|
||||
if (!AddRec->getNoWrapFlags())
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!isLoopInvariant(Step, LoopNest))
|
||||
return false;
|
||||
Loops.set(mapDstLoop(AddRec->getLoop()));
|
||||
@ -942,13 +958,15 @@ bool DependenceAnalysis::isKnownPredicate(ICmpInst::Predicate Pred,
|
||||
// All subscripts are all the same type.
|
||||
// Loop bound may be smaller (e.g., a char).
|
||||
// Should zero extend loop bound, since it's always >= 0.
|
||||
// This routine collects upper bound and extends if needed.
|
||||
// This routine collects upper bound and extends or truncates if needed.
|
||||
// Truncating is safe when subscripts are known not to wrap. Cases without
|
||||
// nowrap flags should have been rejected earlier.
|
||||
// Return null if no bound available.
|
||||
const SCEV *DependenceAnalysis::collectUpperBound(const Loop *L,
|
||||
Type *T) const {
|
||||
if (SE->hasLoopInvariantBackedgeTakenCount(L)) {
|
||||
const SCEV *UB = SE->getBackedgeTakenCount(L);
|
||||
return SE->getNoopOrZeroExtend(UB, T);
|
||||
return SE->getTruncateOrZeroExtend(UB, T);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
Reference in New Issue
Block a user