mir: extract CSE into passes::cse and wire it in optimizer. Behavior preserved (count-only, no SSA rewrites). Build + PyVM Stage-2 smokes PASS.

This commit is contained in:
Selfhosting Dev
2025-09-17 03:41:04 +09:00
parent 56463c75f6
commit 154778fc57
3 changed files with 62 additions and 2 deletions

View File

@ -68,8 +68,11 @@ impl MirOptimizer {
stats.dead_code_eliminated += eliminated;
}
// Pass 2: Pure instruction CSE (Common Subexpression Elimination)
stats.merge(self.common_subexpression_elimination(module));
// Pass 2: Pure instruction CSE (modularized)
{
let eliminated = crate::mir::passes::cse::eliminate_common_subexpressions(module);
stats.cse_eliminated += eliminated;
}
// Pass 3: Pure instruction reordering for better locality
stats.merge(self.reorder_pure_instructions(module));