Skip to content

Commit

Permalink
Add check for values defined above
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Wood <[email protected]>
  • Loading branch information
IanWood1 committed Sep 19, 2024
1 parent ec06464 commit fbfcb84
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions compiler/src/iree/compiler/DispatchCreation/FusionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include "mlir/Analysis/SliceAnalysis.h"
#include "mlir/Dialect/Linalg/IR/Linalg.h"
#include "mlir/IR/Dominance.h"
#include "mlir/IR/OpDefinition.h"
#include "mlir/Transforms/RegionUtils.h"

namespace mlir::iree_compiler::DispatchCreation {

Expand Down Expand Up @@ -113,6 +115,17 @@ bool isHorizontalToGroup(Operation *op, ArrayRef<Operation *> currGroup,
};
llvm::SetVector<Operation *> slice;
getBackwardSlice(op, &slice, options);

// `getBackwardSlice` doesnt track uses from within an ops region, so make
// sure there are no values defined above.
for (Operation *sliceOp : slice) {
llvm::SetVector<Value> valuesDefinedAbove;
mlir::getUsedValuesDefinedAbove(sliceOp->getRegions(), valuesDefinedAbove);
if (valuesDefinedAbove.size()) {
return false;
}
}

return !llvm::any_of(currGroup, [&](Operation *groupedOp) {
return slice.contains(groupedOp);
});
Expand Down

0 comments on commit fbfcb84

Please sign in to comment.