 <p>I don't think the loop will be slower. You are accessing the memory of the M1 and M2 arrays in the same way in both instances i.e. . If you want to make the "manual" version faster then use scalar replacement and do the computation on registers e.g.</p> <pre><code> double M1_0 = M1[0]; double M2_0 = M2[0]; result[0] = M1_0*M2_0 + ... </code></pre> <p>but you can use scalar replacement within the loop as well. You can do it if you do blocking and loop unrolling (in fact your triple loop looks like a blocking version of the MMM).</p> <p>What you are trying to do is to speed up the program by improving locality i.e. better use of the memory hierarchy and better locality.</p>