Talk:Loop-invariant code motion: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 9:
 
However, that transformation is not "loop-invariant code motion". In any case it is not obviously correct when maximum is near overflow (well, OK, maybe it's undefined behaviour then, but suppose that j was unsigned). --[[User:DavidHopwood|DavidHopwood]] 01:16, 29 January 2007 (UTC)
 
---------------------------------
 
As of 10 Apr 2007, this article has:
 
<blockquote>
<pre>
while (j < maximum - 1)
{
j = j + ( 4 + array[ k ] ) * pi + 5;
}
</pre>
<p>The calculation of maximum - 1 and (4+array[k])*pi+5 can be moved outside the loop.</p>
</blockquote>
 
This makes an assumption that the program in question is not threaded. Otherwise, what would be the guarantee that no other thread would modify the value of maximum while this thread was executing that loop? (As for the pre-calculation?)
 
--Kevin