Skip to content

Commit dee817a

Browse files
committed
[mlir] [dataflow] further optimize dataflow compile time
Optimize dataflow compilation time by skipping initialization of irrelevant operations
1 parent 401b5cc commit dee817a

File tree

4 files changed

+19
-0
lines changed

4 files changed

+19
-0
lines changed

mlir/include/mlir/Analysis/DataFlowFramework.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,12 @@ class DataFlowAnalysis {
658658
return solver.getOrCreateState<StateT>(anchor);
659659
}
660660

661+
/// Add irrelevant program point.
662+
template <typename PointT>
663+
void addIrrelevantPoint(PointT point) {
664+
irrelevantPoints.insert(ProgramPoint(point));
665+
}
666+
661667
/// Get a read-only analysis state for the given point and create a dependency
662668
/// on `dependent`. If the return state is updated elsewhere, this analysis is
663669
/// re-invoked on the dependent.
@@ -695,6 +701,9 @@ class DataFlowAnalysis {
695701
StringRef debugName;
696702
#endif // LLVM_ENABLE_ABI_BREAKING_CHECKS
697703

704+
/// Program points shouldn't analyzed by this analysis.
705+
DenseSet<ProgramPoint> irrelevantPoints;
706+
698707
private:
699708
/// The parent data-flow solver.
700709
DataFlowSolver &solver;

mlir/lib/Analysis/DataFlow/DenseAnalysis.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ void AbstractDenseForwardDataFlowAnalysis::visitCallOperation(
104104

105105
LogicalResult
106106
AbstractDenseForwardDataFlowAnalysis::processOperation(Operation *op) {
107+
// Skip irrelavant program points.
108+
if (irrelevantPoints.contains(ProgramPoint(op)))
109+
return;
110+
107111
ProgramPoint *point = getProgramPointAfter(op);
108112
// If the containing block is not executable, bail out.
109113
if (op->getBlock() != nullptr &&
@@ -333,6 +337,10 @@ void AbstractDenseBackwardDataFlowAnalysis::visitCallOperation(
333337

334338
LogicalResult
335339
AbstractDenseBackwardDataFlowAnalysis::processOperation(Operation *op) {
340+
// Skip irrelavant program points.
341+
if (irrelevantPoints.contains(ProgramPoint(op)))
342+
return;
343+
336344
ProgramPoint *point = getProgramPointBefore(op);
337345
// If the containing block is not executable, bail out.
338346
if (op->getBlock() != nullptr &&

mlir/test/lib/Analysis/DataFlow/TestDenseBackwardDataFlowAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ LogicalResult NextAccessAnalysis::visitOperation(Operation *op,
147147

148148
void NextAccessAnalysis::buildOperationEquivalentLatticeAnchor(Operation *op) {
149149
if (isMemoryEffectFree(op)) {
150+
addIrrelevantPoint(op);
150151
unionLatticeAnchors<NextAccess>(getProgramPointBefore(op),
151152
getProgramPointAfter(op));
152153
}

mlir/test/lib/Analysis/DataFlow/TestDenseForwardDataFlowAnalysis.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ LogicalResult LastModifiedAnalysis::visitOperation(
154154
void LastModifiedAnalysis::buildOperationEquivalentLatticeAnchor(
155155
Operation *op) {
156156
if (isMemoryEffectFree(op)) {
157+
addIrrelevantPoint(op);
157158
unionLatticeAnchors<LastModification>(getProgramPointBefore(op),
158159
getProgramPointAfter(op));
159160
}

0 commit comments

Comments
 (0)