Hi, I have a question. Is your case only applicable to loop body sink = &source[i]?
If there is only sink = &source[i], then the loop should be optimized to a single store in DSE,
as the first len(source)-2 times of assignments are not read by anyone.
If there are other functions in loop, as the slice length is taken snapshot at beginning of the loop,
once the slice is modified inside loop(unreasonable but permitted), the bounds check is still necessary.
Thanks @randall77. Disregard this. I was observing a bounds check in for range code in a larger part of complex code. I was trying to reduce it to a smaller reproduction and accidentally introduced the bounds check for a different reason (i.e., using a global variable for the slice).
Looking more into my specific example, it appears that the compiler is unable to prove that some deeply recursive function calls will not mutate the slice, and thus cause the length to change.