Skip to content

Commit b1fb869

Browse files
committed
Optimize: Merge more instructions
1 parent f9862f0 commit b1fb869

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/Lua/CodeAnalysis/Compilation/FunctionCompilationContext.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public void PushOrMergeInstruction(int lastLocal,in Instruction instruction, in
138138
case OpCode.Div:
139139
case OpCode.Mod:
140140
case OpCode.Pow:
141+
case OpCode.Concat:
141142
{
142143
lastInstruction.A = instruction.A;
143144
incrementStackPosition = false;
@@ -199,14 +200,13 @@ public void PushOrMergeInstruction(int lastLocal,in Instruction instruction, in
199200
break;
200201
}
201202
case OpCode.Unm:
202-
if (lastInstruction.OpCode == OpCode.Move && lastLocal != lastInstruction.A)
203+
case OpCode.Not:
204+
case OpCode.Len:
205+
if (lastInstruction.OpCode == OpCode.Move && lastLocal != lastInstruction.A && lastInstruction.A == instruction.B)
203206
{
204-
if (lastInstruction.A == instruction.B)
205-
{
206-
lastInstruction=Instruction.Unm(instruction.A, lastInstruction.B);
207-
incrementStackPosition = false;
208-
return;
209-
}
207+
lastInstruction = instruction with { B = lastInstruction.B };;
208+
incrementStackPosition = false;
209+
return;
210210
}
211211
break;
212212
}

0 commit comments

Comments
 (0)