On Thu, 31 Oct 2024 at 20:05, Matthew Kolbe via Std-Proposals <std-proposals@lists.isocpp.org> wrote:> You can tell the compiler that this is safe either by loading both values before the ifAs I mentioned in my other email, this is true (and I believe the best work around). My two objections are that it's now two more lines of code. The other is that taking both paths is no longer an available optimization, but instead part of the code. So, even when it doesn't vectorize, there's now an additional load that happens for all compilations.Not necessarily: https://godbolt.org/z/4h8eoe6EaThe optimized code is identical whether you do two loads and only use one of them, or only do one load. In the case where you do two loads, one is dead code that can be removed. But it still tells the compiler that performing that load is not undefined, so the indices i and i+1 must be within the array bounds.