I have watched a compiler flip between emitting the code I expected (despite it having UB), and emitting unexpected code after a minor update.
What you observe a compiler do when there's UB is not at all something you can rely on.