-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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: add rewrite rules for arithmetic operations #59111
Labels
Milestone
Comments
Sure. |
y1yang0
added a commit
to y1yang0/go
that referenced
this issue
Mar 19, 2023
To align other popular compilers, add the following common local transformations (t + x) - (t + y) == x - y (t + x) - (y + t) == x - y (x + t) - (y + t) == x - y (x + t) - (t + y) == x - y (x - t) + (t + y) == x + y (x - t) + (y + t) == x + y Fixes golang#59111
y1yang0
added a commit
to y1yang0/go
that referenced
this issue
Mar 19, 2023
To align other popular compilers, add the following common local transformations (t + x) - (t + y) == x - y (t + x) - (y + t) == x - y (x + t) - (y + t) == x - y (x + t) - (t + y) == x - y (x - t) + (t + y) == x + y (x - t) + (y + t) == x + y Fixes golang#59111
y1yang0
added a commit
to y1yang0/go
that referenced
this issue
Mar 19, 2023
To align other popular compilers, add the following common local transformations (t + x) - (t + y) == x - y (t + x) - (y + t) == x - y (x + t) - (y + t) == x - y (x + t) - (t + y) == x - y (x - t) + (t + y) == x + y (x - t) + (y + t) == x + y Fixes golang#59111
y1yang0
added a commit
to y1yang0/go
that referenced
this issue
Mar 19, 2023
Add the following common local transformations (t + x) - (t + y) == x - y (t + x) - (y + t) == x - y (x + t) - (y + t) == x - y (x + t) - (t + y) == x - y (x - t) + (t + y) == x + y (x - t) + (y + t) == x + y The compiler itself matches such patterns many times. This also aligns with other popular compilers. Fixes golang#59111
Change https://go.dev/cl/477555 mentions this issue: |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Hi, I found that we have a potential local optimization for subtraction involving common integers, which is also implemented in other compilers. i.e.
(t + x) - (t + y) ==> x - y
. The compiler itself matches such a pattern 303 times after a quick try, it seems that this could be a candidate for generic rules. I'd like to add it if you think it's worth doing. Thanks for your patience.What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: