Skip to content
New issue

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.

Already on GitHub? Sign in to your account

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

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

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

mundaym 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

Comments

@mundaym
Copy link
Member

mundaym commented Apr 28, 2020

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
@mundaym mundaym added this to the Unplanned milestone Apr 28, 2020
@mundaym mundaym self-assigned this Apr 28, 2020
@gopherbot
Copy link
Contributor

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

@rsc rsc unassigned mundaym Jun 23, 2022
@cagedmantis cagedmantis 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
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 13, 2022
@gopherbot
Copy link
Contributor

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

Sign up for free 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