/ go Public

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

# cmd/compile: experiment with more integer comparison optimizations#38721

Open
opened this issue Apr 28, 2020 · 2 comments
Open

# cmd/compile: experiment with more integer comparison optimizations #38721

opened this issue Apr 28, 2020 · 2 comments
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

### mundaym commented Apr 28, 2020 • edited Loading

In Go 1.15 we've added support for integer-in-range optimizations to the SSA backend. This same infrastructure (mostly in https://github.com/golang/go/blob/master/src/cmd/compile/internal/ssa/fuse_comparisons.go) can quite easily be extended to perform other potential control flow transformations. I've opened this issue in order to track them and get more ideas.

Note: these transformations may or may not be worthwhile optimizations.

Disjunctions (||):

Before After Comments CL (if applicable)
`x == 1 || x == 2` `uint(x - 1) <= 1` Integer range CL 224878
`x == 4 || x == 6` `x|2 == 6` Power of 2 difference CL 471815
`x != 0 || y != 0` `x|y != 0` Neq with 0
`x < 0 || y < 0` `x|y < 0` Less with 0
`x >= 0 || y >= 0` `x&y >= 0` Geq with 0

Conjunctions (&&):

Before After Comments CL (if applicable)
`x != 1 && x != 2` `uint(x - 1) > 1` Integer range CL 224878
`x != 4 && x != 6` `x|2 != 6` Power of 2 difference CL 471815
`x == 0 && y == 0` `x|y == 0` Eq with 0
`x < 0 && y < 0` `x&y < 0` Less with 0
`x >= 0 && y >= 0` `x|y >= 0` Geq with 0
added this to the Unplanned milestone Apr 28, 2020
self-assigned this Apr 28, 2020

### gopherbot commented Apr 28, 2020

 Change https://golang.org/cl/224878 mentions this issue: `cmd/compile: add more integer-in-range optimizations`

unassigned mundaym Jun 23, 2022
added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 23, 2022
mentioned this issue Jul 1, 2022
added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022

### gopherbot commented Feb 27, 2023

 Change https://go.dev/cl/471815 mentions this issue: `cmd/compile: optimize comparisons with constants`

to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

3 participants