Lab6: Implement DominatorTree-based natural loop discovery and loop-invariant code motion hoisting pass
This commit is contained in:
@@ -4,13 +4,11 @@
|
||||
namespace ir {
|
||||
|
||||
void RunFunctionOptimizationPasses(Function* func, Context& ctx) {
|
||||
// 1. Promote memory-based local variables to SSA form using Mem2Reg
|
||||
RunMem2Reg(func, ctx);
|
||||
|
||||
// 2. Run scalar optimizations iteratively until convergence (no changes observed)
|
||||
bool changed = true;
|
||||
int iterations = 0;
|
||||
const int max_iterations = 16; // Safe limit to prevent compile-time infinite loops
|
||||
const int max_iterations = 16;
|
||||
|
||||
while (changed && iterations < max_iterations) {
|
||||
changed = false;
|
||||
@@ -19,6 +17,7 @@ void RunFunctionOptimizationPasses(Function* func, Context& ctx) {
|
||||
changed |= RunConstProp(func, ctx);
|
||||
changed |= RunConstFold(func, ctx);
|
||||
changed |= RunCSE(func);
|
||||
changed |= RunLICM(func);
|
||||
changed |= RunDCE(func);
|
||||
changed |= RunCFGSimplify(func);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user