Sure, but I don't agree that disabling safety checks is an "optimization". It is a regression in functionality that is betting on nothing going wrong.
Bounds checks do not cost much[1]. Maybe if a bounds check disables vectorization[2].
[1] https://blog.readyset.io/bounds-checks/
[2] https://github.com/matklad/bounds-check-cost
There are a lot of techniques to remove bounds checks, e.g. in counted loops [3][4].
[3] https://ieeexplore.ieee.org/document/5381765
[4] https://en.wikipedia.org/wiki/Bounds-checking_elimination