Talk:Loop-invariant code motion: Difference between revisions

Content deleted Content added
Line 51:
:"''[...] strength reduction could remove the two multiplications inside the loop (6*i and a[i]) [...]''"
Via [[C syntax]] and [[pointer arithmetic]], '''a[i]''' can also be interpreted as '''*(a + i)'''. Can someone tell where the hidden multiplication is taking place? --[[User:Abdull|Abdull]] ([[User talk:Abdull|talk]]) 12:56, 29 October 2010 (UTC)
:When doing pointer arithmetic, the index needs to be scaled by the pointer target's size: if <code>a</code> has type <code>int*</code>, then <code>*(a + i)</code> is equal to <code>*(int*) (((char*) a) + (i * sizeof(int)))</code>. [[User:Alksentrs|Alksentrs]] ([[User talk:Alksentrs|talk]]) 16:44, 29 October 2010 (UTC)