Fix ATI problems with Chrome v39 Beta

Non-constant array access causes problems with Chrome v39 Beta. I've solved the problem by loop unrolling.