emit_arm64_data_processing: EmitAddSub: Handle zero immediate w/ flag output

This commit is contained in:
Merry 2022-07-30 12:32:11 +01:00 committed by merry
parent cd537dc711
commit 0692f1d40e

View file

@ -713,9 +713,17 @@ static void EmitAddSub(oaknut::CodeGenerator& code, EmitContext& ctx, IR::Inst*
RegAlloc::Realize(Rresult, Ra);
ctx.reg_alloc.ReadWriteFlags(args[2], nzcv_inst);
if (imm == 0) {
if constexpr (bitsize == 32) {
sub ? code.SBCS(Rresult, Ra, WZR) : code.ADCS(Rresult, Ra, WZR);
} else {
sub ? code.SBCS(Rresult, Ra, XZR) : code.ADCS(Rresult, Ra, XZR);
}
} else {
code.MOV(Rscratch0<bitsize>(), imm);
sub ? code.SBCS(Rresult, Ra, Rscratch0<bitsize>()) : code.ADCS(Rresult, Ra, Rscratch0<bitsize>());
}
}
} else {
auto Rb = ctx.reg_alloc.ReadReg<bitsize>(args[1]);