> The actual issue is that the compiler is free to eliminate code paths after UB
Not, that the compiler can also emit code paths before UB, as UB is a property of the whole program, not just of a single statement.