cmd/compile: optimize xor to complement #39710
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Performance
Milestone
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Tried to flip bits in a large section of a bitmap using
^= ^uint64(0)
in a loop.What did you expect to see?
The compiler treats this as a bitwise complement operation.
What did you see instead?
The compiler emits an xor against a constant, and treats it differently than a bitwise complement.
https://godbolt.org/z/vxQyD3
If I understand correctly, this could be solved by adding the following rule to
generic.rules
:The text was updated successfully, but these errors were encountered: