public override void OptimizeOperations(MethodInterpreter 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(MethodInterpreter midRepresentation) { var loopStarts = LoopDetection.FindLoops(midRepresentation.MidRepresentation); return(loopStarts.Count != 0); }