fix(ir): LoopUnroll 限制 i32 函数 + 支持 float cast 克隆

- 跳过非 i32 返回值函数(float 循环体含不支持的浮点二元操作)
- 添加 SIToFP/FPToSI 到 CloneInstruction
- 修复 35_math/38_light2d 编译崩溃

门禁:functional 99/100, h_functional 40/40
lzk
lzkk 2 days ago
parent 608aa98f4e
commit ec8c874829

@ -122,6 +122,11 @@ static std::unique_ptr<Instruction> CloneInstruction(
return std::make_unique<CastInst>(op, inst->GetType(),
map(cast->GetOperandValue()), ctx.NextTemp());
}
case Opcode::SIToFP: case Opcode::FPToSI: {
auto* cast = static_cast<CastInst*>(inst);
return std::make_unique<CastInst>(op, inst->GetType(),
map(cast->GetOperandValue()), ctx.NextTemp());
}
case Opcode::Br: {
auto* br = static_cast<BranchInst*>(inst);
return std::make_unique<BranchInst>(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;

Loading…
Cancel
Save