Instance based locality optimization 6 is a semi automatic program restructuring method that reduces the number of cache misses. The method imitates the human approach of considering several small program instances, optimizing the instances, and generalizing the structure of the solutions to the program under consideration. A program instance appears as a sequence of statement instances that are reordered for better locality. In 6 , a local search algorithm was introduced that reorders the statement instances automatically. This paper supplements 6 by introducing a second objective into the optimization algorithm for program instances: regularity. A sequence of statement instances is called regular if it can be written compactly using loops. We quantify the intuitive notion of regularity in an objective function, and incorporate this function into the local search algorithm. The functionality of the compound algorithm is demonstrated with examples, that also show trade o s between loca...