cmd/compile: treat bool-to-int conversion as a constant for optimization for more complex patterns #62049
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FeatureRequest
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
A common argument against #9367 and #45320 is that it's trivial to just write a helper function to convert bools to ints.
However, this breaks compiler optimizations related to constant propagation.
Consider the following benchmark:
Both
WithRed
andWithGreen
are semantically equivalent, butWithGreen
is dramatically faster as it does not allocate.Barring the acceptance of #9367 or #45320, we should make the compiler make constant propagation work across bool-to-int helpers.
The text was updated successfully, but these errors were encountered: