Skip to content

Commit

Permalink
Fixed Ourpalm#721
Browse files Browse the repository at this point in the history
  • Loading branch information
liiir1985 committed Jul 25, 2022
1 parent 63a0912 commit 1bf7b7c
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 21 deletions.
6 changes: 3 additions & 3 deletions ILRuntime/Runtime/Intepreter/RegisterVM/Optimizer.BCP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,17 @@ public static void BackwardsCopyPropagation(List<CodeBasicBlock> blocks, bool ha
GetOpcodeDestRegister(ref Z, out zDst);
if (GetOpcodeSourceRegister(ref Z, hasReturn, out zSrc, out zSrc2, out zSrc3))
{
if(zSrc == yDst && CanReplaceOpcodeSource(ref Z, 0))
if(zSrc == yDst)
{
replaced = true;
ReplaceOpcodeSource(ref Z, 0, xDst);
}
if (zSrc2 == yDst && CanReplaceOpcodeSource(ref Z, 1))
if (zSrc2 == yDst)
{
replaced = true;
ReplaceOpcodeSource(ref Z, 1, xDst);
}
if (zSrc3 == yDst && CanReplaceOpcodeSource(ref Z, 2))
if (zSrc3 == yDst)
{
replaced = true;
ReplaceOpcodeSource(ref Z, 2, xDst);
Expand Down
84 changes: 66 additions & 18 deletions ILRuntime/Runtime/Intepreter/RegisterVM/Optimizer.FCP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void ForwardCopyPropagation(List<CodeBasicBlock> blocks, bool hasR
if (GetOpcodeSourceRegister(ref Y, hasReturn, out ySrc, out ySrc2, out ySrc3))
{
bool replaced = false;
if (ySrc >= 0 && ySrc == xDst && CanReplaceOpcodeSource(ref Y, 0))
if (ySrc >= 0 && ySrc == xDst)
{
if (postPropagation)
{
Expand All @@ -86,10 +86,18 @@ public static void ForwardCopyPropagation(List<CodeBasicBlock> blocks, bool hasR
ended = true;
break;
}
ReplaceOpcodeSource(ref Y, 0, xSrc);
replaced = true;
if (CanReplaceOpcodeSource(ref Y, 0))
{
ReplaceOpcodeSource(ref Y, 0, xSrc);
replaced = true;
}
else
{
ended = true;
break;
}
}
if (ySrc2 >= 0 && ySrc2 == xDst && CanReplaceOpcodeSource(ref Y, 1))
if (ySrc2 >= 0 && ySrc2 == xDst)
{
if (postPropagation)
{
Expand All @@ -102,10 +110,18 @@ public static void ForwardCopyPropagation(List<CodeBasicBlock> blocks, bool hasR
ended = true;
break;
}
ReplaceOpcodeSource(ref Y, 1, xSrc);
replaced = true;
if (CanReplaceOpcodeSource(ref Y, 1))
{
ReplaceOpcodeSource(ref Y, 1, xSrc);
replaced = true;
}
else
{
ended = true;
break;
}
}
if (ySrc3 >= 0 && ySrc3 == xDst && CanReplaceOpcodeSource(ref Y, 2))
if (ySrc3 >= 0 && ySrc3 == xDst)
{
if (postPropagation)
{
Expand All @@ -118,8 +134,16 @@ public static void ForwardCopyPropagation(List<CodeBasicBlock> blocks, bool hasR
ended = true;
break;
}
ReplaceOpcodeSource(ref Y, 2, xSrc);
replaced = true;
if (CanReplaceOpcodeSource(ref Y, 2))
{
ReplaceOpcodeSource(ref Y, 2, xSrc);
replaced = true;
}
else
{
ended = true;
break;
}
}

if (replaced)
Expand Down Expand Up @@ -208,35 +232,59 @@ public static void ForwardCopyPropagation(List<CodeBasicBlock> blocks, bool hasR
if (GetOpcodeSourceRegister(ref Y, hasReturn, out ySrc, out ySrc2, out ySrc3))
{
bool replaced = false;
if (ySrc == xDst && CanReplaceOpcodeSource(ref Y, 0))
if (ySrc == xDst)
{
if (propagationInline || cur.PreviousBlocks.Count > 1)
{
cannotRemove = true;
break;
}
replaced = true;
ReplaceOpcodeSource(ref Y, 0, xSrc);
if (CanReplaceOpcodeSource(ref Y, 0))
{
replaced = true;
ReplaceOpcodeSource(ref Y, 0, xSrc);
}
else
{
cannotRemove = true;
break;
}
}
if (ySrc2 == xDst && CanReplaceOpcodeSource(ref Y, 1))
if (ySrc2 == xDst)
{
if (propagationInline || cur.PreviousBlocks.Count > 1)
{
cannotRemove = true;
break;
}
replaced = true;
ReplaceOpcodeSource(ref Y, 1, xSrc);
if (CanReplaceOpcodeSource(ref Y, 1))
{
replaced = true;
ReplaceOpcodeSource(ref Y, 1, xSrc);
}
else
{
cannotRemove = true;
break;
}
}
if (ySrc3 == xDst && CanReplaceOpcodeSource(ref Y, 2))
if (ySrc3 == xDst)
{
if (propagationInline || cur.PreviousBlocks.Count > 1)
{
cannotRemove = true;
break;
}
replaced = true;
ReplaceOpcodeSource(ref Y, 2, xSrc);
if (CanReplaceOpcodeSource(ref Y, 2))
{
replaced = true;
ReplaceOpcodeSource(ref Y, 2, xSrc);
}
else
{
cannotRemove = true;
break;
}
}

if (replaced)
Expand Down

0 comments on commit 1bf7b7c

Please sign in to comment.