cmd/compile: experiment with more integer comparison optimizations #38721
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
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 (||):
x == 1 || x == 2
uint(x - 1) <= 1
x == 4 || x == 6
x|2 == 6
x != 0 || y != 0
x|y != 0
x < 0 || y < 0
x|y < 0
x >= 0 || y >= 0
x&y >= 0
Conjunctions (&&):
x != 1 && x != 2
uint(x - 1) > 1
x != 4 && x != 6
x|2 != 6
x == 0 && y == 0
x|y == 0
x < 0 && y < 0
x&y < 0
x >= 0 && y >= 0
x|y >= 0
The text was updated successfully, but these errors were encountered: