]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: optimize comparisons with single bit difference
authorMichael Munday <mndygolang+git@gmail.com>
Tue, 26 Aug 2025 20:17:36 +0000 (21:17 +0100)
committerGopher Robot <gobot@golang.org>
Fri, 14 Nov 2025 18:59:56 +0000 (10:59 -0800)
commit0a569528ea355099af864f7612c3fa1973df30e4
tree189f828573801d88d072ebd988ae1d553d2a8afa
parent1e5e6663e958dcc9579fb38ffcd8a1999d75128d
cmd/compile: optimize comparisons with single bit difference

Optimize comparisons with constants that only differ by 1 bit (i.e.
a power of 2). For example:

    x == 4 || x == 6 -> x|2 == 6
    x != 1 && x != 5 -> x|4 != 5

Change-Id: Ic61719e5118446d21cf15652d9da22f7d95b2a15
Reviewed-on: https://go-review.googlesource.com/c/go/+/719420
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/cmd/compile/internal/ssa/_gen/generic.rules
src/cmd/compile/internal/ssa/fuse.go
src/cmd/compile/internal/ssa/fuse_comparisons.go
src/cmd/compile/internal/ssa/rewritegeneric.go
test/codegen/fuse.go