@@ -1083,7 +1083,7 @@ LogicalResult mlir::moveOperationDependencies(RewriterBase &rewriter,
1083
1083
// depends on. Prune the slice to only include operations not already
1084
1084
// dominated by the `insertionPoint`
1085
1085
BackwardSliceOptions options;
1086
- options.inclusive = true ;
1086
+ options.inclusive = false ;
1087
1087
options.omitUsesFromAbove = false ;
1088
1088
// Since current support is to only move within a same basic block,
1089
1089
// the slices dont need to look past block arguments.
@@ -1092,20 +1092,7 @@ LogicalResult mlir::moveOperationDependencies(RewriterBase &rewriter,
1092
1092
return !dominance.properlyDominates (sliceBoundaryOp, insertionPoint);
1093
1093
};
1094
1094
llvm::SetVector<Operation *> slice;
1095
-
1096
- // Get the defined slice for operands.
1097
- for (Value operand : op->getOperands ()) {
1098
- getBackwardSlice (operand, &slice, options);
1099
- }
1100
- auto regions = op->getRegions ();
1101
- if (!regions.empty ()) {
1102
- // If op has region, get the defined slice for all captured values.
1103
- llvm::SetVector<Value> capturedVals;
1104
- mlir::getUsedValuesDefinedAbove (regions, capturedVals);
1105
- for (Value value : capturedVals) {
1106
- getBackwardSlice (value, &slice, options);
1107
- }
1108
- }
1095
+ getBackwardSlice (op, &slice, options);
1109
1096
1110
1097
// If the slice contains `insertionPoint` cannot move the dependencies.
1111
1098
if (slice.contains (insertionPoint)) {
@@ -1114,8 +1101,8 @@ LogicalResult mlir::moveOperationDependencies(RewriterBase &rewriter,
1114
1101
" cannot move dependencies before operation in backward slice of op" );
1115
1102
}
1116
1103
1117
- // Sort the slice topologically, and move in topological order.
1118
- mlir::topologicalSort (slice);
1104
+ // We should move the slice in topological order, but `getBackwardSlice`
1105
+ // already does that. So no need to sort again.
1119
1106
for (Operation *op : slice) {
1120
1107
rewriter.moveOpBefore (op, insertionPoint);
1121
1108
}
0 commit comments