Changing t=t+j
(outher loop variable) to t=t+9
inside two nested for loops increased runtime more than 10%. How this can be possible?
for(int j=-1048576;j<1048576;j+=2000)
for(int i=-1048576;i<1048576;i++)
t+=9;//t+=j
CPU:Celeron N3350
I look at assembly of both binaries. Only difference I notice:
t=t+9 :
addl $9, -4(%rbp)
t=t+j :
movl -8(%rbp), %eax
addl %eax, -4(%rbp)