You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cmd/compile is emitting calls to runtime.stringtoslicebyte when it could/should be using runtime.stringtoslicebytetmp instead:
$ cat sum.go
package f
func sum(s string) byte {
var x byte
for _, c := range []byte(s) {
x += c
}
return x
}
$ go tool compile -S sum.go | grep stringtoslice
0x0030 00048 (sum.go:5) CALL runtime.stringtoslicebyte(SB)
rel 49+4 t=6 runtime.stringtoslicebyte+0
To answer my own question, TestCompareTempString and TestRangeStringCast were both using test strings short enough to fit into the 32-byte tmpBuf stack storage, so they weren't testing the intended compiler optimizations.
On the upside, TestCompareTempString's optimization was already working correctly.
cmd/compile is emitting calls to runtime.stringtoslicebyte when it could/should be using runtime.stringtoslicebytetmp instead:
Noticed during review of CL 21173.
The text was updated successfully, but these errors were encountered: