cmd/compile: bits.Len of constant not constant-folded #58588
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
Performance
Milestone
What version of Go are you using (
go version
)?What did you do?
What did you expect to see?
A single shift instruction after constant folding.
What did you see instead?
With GOARCH=amd64, GOAMD64=v2:
Adding a uint cast gets rid of the panicshift call, but still produces more than a dozen instructions.
GOAMD64=v3 produces shorter, but still suboptimal code.
Interestingly, GOARCH=386 does trigger constant folding, but still gets a useless check for 1 < 0:
The text was updated successfully, but these errors were encountered: