a method is provided for minimizing cache misses in a compiled computer program having loop instructions . the compiled computer program is examined to identify a set of compiled loop instructions which is smaller than a cache memory block . the set of compiled loop instructions may straddle two blocks of main memory , which would cause cache misses when the program is executed . the identified set of compiled loop instructions is therefore positioned to fall entirely within the boundaries of a block of main memory so that cache misses are avoided when the set of compiled loop instructions is executed . loop - invariant instructions are removed from the set of compiled loop instructions . when blocks of the main memory unit are mapped into the cache memory in a set - associative manner , external - call locations are mapped into different rows of the main memory then the corresponding loop instructions . as a result , when blocks of main memory are transferred to the cache memory unit , cache misses are avoided .