Skip to content

Commit f9862f0

Browse files
committed
Optimize: MOVE Unm Pattern
1 parent e15f026 commit f9862f0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Lua/CodeAnalysis/Compilation/FunctionCompilationContext.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,17 @@ public void PushOrMergeInstruction(int lastLocal,in Instruction instruction, in
198198
}
199199
break;
200200
}
201+
case OpCode.Unm:
202+
if (lastInstruction.OpCode == OpCode.Move && lastLocal != lastInstruction.A)
203+
{
204+
if (lastInstruction.A == instruction.B)
205+
{
206+
lastInstruction=Instruction.Unm(instruction.A, lastInstruction.B);
207+
incrementStackPosition = false;
208+
return;
209+
}
210+
}
211+
break;
201212
}
202213

203214
instructions.Add(instruction);

0 commit comments

Comments
 (0)