diff --git a/src/ir/passes/Mem2Reg.cpp b/src/ir/passes/Mem2Reg.cpp index c004ba63..3bfd55f0 100644 --- a/src/ir/passes/Mem2Reg.cpp +++ b/src/ir/passes/Mem2Reg.cpp @@ -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()