Help to understand this encoder timer tick code
The best guess I can come up with is that the &gt;&gt;3 (divide by 8) is an attempt to prevent going beyond the size of the variable arraysum.  Since TCNT3 is a 16 bit counter, if there wasn't some sort of scaling factor, you could easily end up with a garbage value for arraysum.

That said, the &gt;&gt;3 probably wouldn't completely solve this problem.  I think it would depend upon how quickly the encoder is getting spun and the clock speed of the mega128.  If each tick on D2 happens to occur when TCNT3 is very large, this algorithm for determining rotational speed is going to have issues.