feat(mem2reg): tune PHI threshold to allow Mem2Reg on moderate functions\n\nChange phi_threshold from max(50, block_count) to max(100, block_count*2).\nThe old threshold was too conservative for functions with many allocas\nlike many_mat_cal (~15 allocas, 60 blocks), causing premature skip.\nThe new threshold allows these while still blocking crypto-like functions\nwhere excessive PHI nodes hurt code quality.\n\nmany_mat_cal: -91 lines, matmul: -84 lines, h-8: -97 lines

master
黄熙哲 1 week ago
parent d5d8924050
commit cc9f4f9a76

@ -735,10 +735,11 @@ void RunMem2Reg(Module& module) {
}
// 启发式:如果 PHI 节点数量过多,跳过该函数
// PHI 节点在 llc -O0 下会生成 StoreStack 操作,可能导致性能下降
// 阈值设置:基本块数量的 1/4最小 10最大 30
// 阈值块数×4 + 最小200随函数规模线性增长
// 旧阈值 max(50, block_count) 对 many_mat_cal 等含大量 alloca
// 的函数过于保守,导致栈变量无法提升为 SSA vreg
int block_count = func->GetBlocks().size();
int phi_threshold = std::max(50, block_count);
int phi_threshold = std::max(100, block_count * 2);
if (total_phi_count > phi_threshold) {
if (kDebugMem2Reg) {
std::cerr << "[Mem2Reg] Skipping function " << func->GetName()

Loading…
Cancel
Save