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 · 1 comment
Open

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

mundaym opened this issue Apr 28, 2020 · 1 comment
Labels
NeedsInvestigation Performance
Milestone

Comments

@mundaym
Copy link
Member

@mundaym 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
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
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

@gopherbot gopherbot commented Apr 28, 2020

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 label Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Performance
Projects
None yet
Development

No branches or pull requests

3 participants