public override void OptimizeOperations(CilMethodInterpreter interpreter) { var midRepresentation = interpreter.MidRepresentation; var useDef = midRepresentation.UseDef; var loopStarts = LoopDetection.FindLoops(midRepresentation); foreach (var loopStart in loopStarts) { var loopEnd = LoopDetection.GetEndLoop(useDef.GetLocalOperations(), loopStart); var allDefinedVariables = GetAllDefinedVariables(midRepresentation, loopStart, loopEnd); var allInvariantInstructions = GetAllInvariantInstructions(midRepresentation, loopStart, loopEnd, allDefinedVariables); if (allInvariantInstructions.Count == 0) { continue; } PerformMoveInstructions(midRepresentation, loopStart, allInvariantInstructions); Result = true; return; } }
public override bool CheckPreconditions(CilMethodInterpreter midRepresentation, ClosureEntities closure) { var loopStarts = LoopDetection.FindLoops(midRepresentation.MidRepresentation); return(loopStarts.Count != 0); }