Patent ID: 8327344

Claim:
A method, in a data processing system, for optimizing loops with conditional control flow in source code based on array reference safety, comprising: analyzing blocks of the source code to identify a conditional control flow loop having loop source code specifying a total access range for an array reference, identifying a safe access range, of the total access range of the array reference in the loop source code, over which a compiler-based optimization of the loop source code can be safely applied without introducing new exception conditions; performing the compiler-based optimization of the loop source code based on the identified safe access range to generate optimized code; and outputting the optimized code for generation of executable code for execution on a processor, wherein identifying the safe access range of the total access range of the array reference in the loop source code comprises: determining a first access range of the array reference over which the loop source code is safe for the compiler-based optimization of the loop source code; determining a second access range of the array reference over which the loop is unsafe for the compiler-based optimization of the loop source code; and performing the compiler-based optimization of the loop source code based on the identification of the first access range and second access range, and wherein determining a first access range of the array reference over which the loop is safe for the compiler-based optimization comprises determining an access range of the array reference that is encountered regardless of which conditional path of the loop is taken when the source code is executed.