Arun Chauhan and Ken Kennedy (2003)
Slice-hoisting for Array-size Inference in MATLAB
In: Proceedings of the 16th International Workshop on Languages and Compilers for Computing (LCPC), ed. by Laurence Rauchwerger, pp. 495–508, Springer-Verlag.
Inferring variable types precisely is very important to be able to compile MATLAB libraries effectively in the context of the telescoping languages framework being developed at Rice. Past studies have demonstrated the value of type information in optimizing MATLAB. The variable types are inferred through a static approach based on writing propositional constraints on program statements. The static approach has certain limitations with respect to inferring array-sizes. Imprecise inference of array-sizes can have a drastic affect on the performance of the generated code, especially in those cases where arrays are resized dynamically. The impact of appropriate array allocation is also borne out of earlier studies. This paper presents a new approach to inferring array-sizes, called slice-hoisting. The approach is based on simple code transformations and is easy to implement in a practical compiler. Experimental evaluation shows that slice-hoisting, along with the constraints-based static algorithm, can result in a very high level of precision in inferring MATLAB array sizes.