golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123.49k stars 17.59k forks source link

cmd/compile: loop inversion does not support unsigned numbers #65918

Open Jorropo opened 7 months ago

Jorropo commented 7 months ago

This is duplicate of #61629 but for:

for range uint(x) {
 // ...
}

I didn't implemented it back then since I reused existing scanning code (findIndVar) which only supported signed ops:

https://github.com/golang/go/blob/ef84d62cfc358ff62c60da9ceec754e7a389b5d5/src/cmd/compile/internal/ssa/loopbce.go#L99

I'll submit a patch.

gopherbot commented 7 months ago

Change https://go.dev/cl/566437 mentions this issue: cmd/compile: add very basic unsigned matching to findIndVar