I did check how two different versions of array accesses(indexing vs iterators) are compiled down to assembly with [https://godbolt.org/](Compiler Explorer). I would love to learn more about how array accesses can actually prevent various compiler optimisations, but currently I can't think of any optimizations that could be prevented by array accesses. Any advice would be greatly appreciated! Thank you
Because LLVM would have to prove that the panic will never happen in order to auto-vectorize the loop. Auto-vectorizing loops is a large source of performance gains, so losing it is bad.