forked from OSchip/llvm-project
Use Instruction::isBeforeInBlock instead of a linear scan
- use Instruction::isBeforeInBlock instead of a linear scan in AffineAnalysis.cpp PiperOrigin-RevId: 236235824
This commit is contained in:
parent
ddc6788cc7
commit
229bd9ba21
|
@ -551,13 +551,13 @@ static const Block *getCommonBlock(const MemRefAccess &srcAccess,
|
|||
}
|
||||
|
||||
// Returns true if the ancestor operation instruction of 'srcAccess' appears
|
||||
// before the ancestor operation instruction of 'dstAccess' in the same
|
||||
// instruction block. Returns false otherwise.
|
||||
// before the ancestor operation instruction of 'dstAccess' in the common
|
||||
// ancestral block. Returns false otherwise.
|
||||
// Note that because 'srcAccess' or 'dstAccess' may be nested in conditionals,
|
||||
// the function is named 'srcAppearsBeforeDstInCommonBlock'.
|
||||
// Note that 'numCommonLoops' is the number of contiguous surrounding outer
|
||||
// loops.
|
||||
static bool srcAppearsBeforeDstInCommonBlock(
|
||||
static bool srcAppearsBeforeDstInAncestralBlock(
|
||||
const MemRefAccess &srcAccess, const MemRefAccess &dstAccess,
|
||||
const FlatAffineConstraints &srcDomain, unsigned numCommonLoops) {
|
||||
// Get Block common to 'srcAccess.opInst' and 'dstAccess.opInst'.
|
||||
|
@ -570,16 +570,8 @@ static bool srcAppearsBeforeDstInCommonBlock(
|
|||
auto *dstInst = commonBlock->findAncestorInstInBlock(*dstAccess.opInst);
|
||||
assert(dstInst != nullptr);
|
||||
|
||||
// Do a linear scan to determine whether dstInst comes after srcInst.
|
||||
auto aIter = Block::const_iterator(srcInst);
|
||||
auto bIter = Block::const_iterator(dstInst);
|
||||
auto aBlockStart = srcInst->getBlock()->begin();
|
||||
while (bIter != aBlockStart) {
|
||||
--bIter;
|
||||
if (bIter == aIter)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
// Determine whether dstInst comes after srcInst.
|
||||
return srcInst->isBeforeInBlock(dstInst);
|
||||
}
|
||||
|
||||
// Adds ordering constraints to 'dependenceDomain' based on number of loops
|
||||
|
@ -813,8 +805,8 @@ bool mlir::checkMemrefAccessDependence(
|
|||
unsigned numCommonLoops = getNumCommonLoops(srcDomain, dstDomain);
|
||||
assert(loopDepth <= numCommonLoops + 1);
|
||||
if (loopDepth > numCommonLoops &&
|
||||
!srcAppearsBeforeDstInCommonBlock(srcAccess, dstAccess, srcDomain,
|
||||
numCommonLoops)) {
|
||||
!srcAppearsBeforeDstInAncestralBlock(srcAccess, dstAccess, srcDomain,
|
||||
numCommonLoops)) {
|
||||
return false;
|
||||
}
|
||||
// Build dim and symbol position maps for each access from access operand
|
||||
|
|
Loading…
Reference in New Issue