Rustc produces substantially different code for summing the first N elements of a vector vs. a slice

If you're going to loop over indices like that, then you should always use reslicing to make it clear up-front to LLVM that things are in-bounds. For more info, read

5 Likes