From ec8c8748296229cbfda3fbf1580c9dd37cc45a89 Mon Sep 17 00:00:00 2001 From: lzkk <956449176@qq.com> Date: Thu, 28 May 2026 19:32:57 +0800 Subject: [PATCH] =?UTF-8?q?fix(ir):=20LoopUnroll=20=E9=99=90=E5=88=B6=20i3?= =?UTF-8?q?2=20=E5=87=BD=E6=95=B0=20+=20=E6=94=AF=E6=8C=81=20float=20cast?= =?UTF-8?q?=20=E5=85=8B=E9=9A=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 跳过非 i32 返回值函数(float 循环体含不支持的浮点二元操作) - 添加 SIToFP/FPToSI 到 CloneInstruction - 修复 35_math/38_light2d 编译崩溃 门禁:functional 99/100, h_functional 40/40 --- src/ir/passes/LoopUnroll.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/ir/passes/LoopUnroll.cpp b/src/ir/passes/LoopUnroll.cpp index 21ec1dc1..8c1fceb4 100644 --- a/src/ir/passes/LoopUnroll.cpp +++ b/src/ir/passes/LoopUnroll.cpp @@ -122,6 +122,11 @@ static std::unique_ptr CloneInstruction( return std::make_unique(op, inst->GetType(), map(cast->GetOperandValue()), ctx.NextTemp()); } + case Opcode::SIToFP: case Opcode::FPToSI: { + auto* cast = static_cast(inst); + return std::make_unique(op, inst->GetType(), + map(cast->GetOperandValue()), ctx.NextTemp()); + } case Opcode::Br: { auto* br = static_cast(inst); return std::make_unique(inst->GetType(), br->GetTarget()); @@ -223,6 +228,8 @@ void RunLoopUnroll(Module& module) { int unrolled = 0; for (auto& func : module.GetFunctions()) { if (func->IsExternal()) continue; + // 只处理 i32 返回值函数(float 循环体含不支持克隆的操作) + if (!func->GetType()->IsInt32()) continue; bool changed = true; while (changed) { changed = false;