aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Translation
diff options
context:
space:
mode:
Diffstat (limited to 'ChocolArm64/Translation')
-rw-r--r--ChocolArm64/Translation/ILEmitterCtx.cs10
1 files changed, 9 insertions, 1 deletions
diff --git a/ChocolArm64/Translation/ILEmitterCtx.cs b/ChocolArm64/Translation/ILEmitterCtx.cs
index d4bd93ab..b5ebff75 100644
--- a/ChocolArm64/Translation/ILEmitterCtx.cs
+++ b/ChocolArm64/Translation/ILEmitterCtx.cs
@@ -530,7 +530,15 @@ namespace ChocolArm64.Translation
public void EmitLdflg(int index) => Ldloc(index, IoType.Flag);
public void EmitStflg(int index)
{
- _optOpLastFlagSet = CurrOp;
+ //Set this only if any of the NZCV flag bits were modified.
+ //This is used to ensure that, when emiting a direct IL branch
+ //instruction for compare + branch sequences, we're not expecting
+ //to use comparison values from an old instruction, when in fact
+ //the flags were already overwritten by another instruction further along.
+ if (index >= (int)PState.VBit)
+ {
+ _optOpLastFlagSet = CurrOp;
+ }
Stloc(index, IoType.Flag);
}