https://github.com/golang/go/blob/6c3b5a2798c83d583cb37dba9f39c47300d19f1f/src/cmd/compile/internal/ssa/loopbce.go#L175-L182
This code here assumes the the first successor leads to the loop and that second successor break the loop.
it looks like ssagen always generate the for
keyword this way but if you write a loop using if ... { break }
inside for { ... }
this is usually inverted.
Comment From: gopherbot
Change https://go.dev/cl/685816 mentions this issue: cmd/compile: check domination of loop return in both controls