Skip to content

Commit

Permalink
add LoopInvariantCodeMotion and CSE
Browse files Browse the repository at this point in the history
  • Loading branch information
BRUCE11111 committed May 28, 2024
1 parent d29f038 commit 55348fb
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lib/gc/Transforms/CPUPhysicalResigterPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
#include "mlir/IR/PatternMatch.h"
#include "mlir/Pass/Pass.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Transforms/CSE.h"
#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
#include "mlir/Transforms/LoopInvariantCodeMotionUtils.h"
#include "llvm/Support/Casting.h"
#include <deque>
#include <optional>
Expand Down Expand Up @@ -57,6 +59,7 @@ bool is_innermost_operation(Operation *op) {
inner_most = false;
return WalkResult::interrupt();
}
return WalkResult::advance();
});
return inner_most;
}
Expand Down Expand Up @@ -861,9 +864,10 @@ void generateGroupOpVectorizedIR(
// 3 Update loop result uses
updateLoopResultUses(idx, opGroups.size(), groupResultYeildSet, func,
&forOp.value(), mapOpResultToYield);
moveLoopInvariantCode(forOp.value());
}

/// Pass that lower to tile vector.
/// Pass that lower to physical vector.
struct CPUPhysicalRegisterPass
: public impl::CPUPhysicalRegisterPassBase<CPUPhysicalRegisterPass> {

Expand All @@ -882,6 +886,8 @@ struct CPUPhysicalRegisterPass
// dependency.
// d. reduction. Need to analysis broadcast dim and the
// data dependency.
// Same group operations have no data dependencies. They can be fused into a
// common for loop body.

// Using queue to store the operation order. In order to ensure that
// subsequent moves to the operation will not cause semantic changes.
Expand Down Expand Up @@ -953,6 +959,9 @@ struct CPUPhysicalRegisterPass
groupOpDestination, mapOpResultToYield, func,
opPermuationMap);
}
DominanceInfo domInfo;
auto reWriter = IRRewriter(func);
eliminateCommonSubExpressions(reWriter, domInfo, func);
}
};
} // namespace
Expand Down
1 change: 1 addition & 0 deletions lib/gc/Transforms/LowerTileVectorPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ bool is_innermost_ir(Operation *op) {
inner_most = false;
return WalkResult::interrupt();
}
return WalkResult::advance();
});
return inner_most;
}
Expand Down

0 comments on commit 55348fb

Please sign in to comment.