Patent ID: 8621430

Claim:
A method comprising: extracting a set of statements from an original code, based on user selection, to yield an extracted set of statements and a residual code that includes portions of the original code, wherein two or more of the extracted statements are not on a same loop in the original code; adding conditions from the original code to the extracted set of statements, to yield an enhanced set of statements, such that the added conditions are sufficient to render the enhanced set of statements executable while preserving semantics of the original code; adding statements from the original code to the residual code, to yield an enhanced residual code, such that the added statements are sufficient to render the enhanced residual code executable while preserving semantics of the original code; adding code portions and a stream of variables to the enhanced set of statements and to the enhanced residual code, such that the data flow between the enhanced set of statements and the enhanced residual code is defined by the data flow in the original code coupled with streaming of data based on the stream of variables; generating a call to the set of statements from the enhanced residual code, the call for executing the enhanced set of statements; and determining a location in the enhanced residual code for an insertion of the call to the enhanced set of statements, wherein at least one of: the extracting, any of the adding, the generating, and the determining is carried out by at least one processor, wherein in the determining, the location is selected such that it satisfies all of: (i) the location is contained in exactly a number of control cycles as a highest location in the original code that postdominates the set of statements; (ii) the location is dominated by all sources of parameters to the enhanced extracted set of statement; (iii) every path from the location to any of added enqueue operations pass through a lowest statement in the original code that dominates the set of statements; and (iv) the location dominates each statements containing uninitialized variables in the residual code.