2 ms·
Is this just a very smart optimizer that can reduce tot=x+x+x+x+x+x+x+x+x+x+x+x+x+x+x to x2=x+x x4=x2+x2 x8=x4+x4 tot=x+x2+x4+x8 or I am missing s
by gus_massa 8y ago
Is this just a very smart optimizer that can reduce
tot=x+x+x+x+x+x+x+x+x+x+x+x+x+x+x
to
x2=x+x
x4=x2+x2
x8=x4+x4
tot=x+x2+x4+x8
or I am missing something?
Note that the first code is O(N=15) and the second one is O(log(N)=4).