-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: migrate amd64-specific optimizations to generic optimizations #16270
Comments
We can do this in generic rules like:
(and the symmetries thereof.) I think we should do these as much as possible in generic.rules. These rules were originally put in AMD64.rules because ANDL gets generated by the shift lowerings. That may not be the case for all architectures. |
Regarding optimizing chains of AND/ADD/XOR/OR: there was a paper (I need to look it up again) that described how to do this for general case instead of having many rewrite rules for every usecase. We might want to implement that as separate pass. |
I'm going to close this.
I'm not sure what else might be done for this issue. Someone could do a pass to see if there are rules in the arch-specific files which are redundant with the generic rules, and where those lowered ops aren't introduced by other lowering rules. Seems not worth people's time. It would be nice to have a general "rule can't ever fire" detector, which would catch this case and others. I had a rule coverage CL working at one point. It helped, but there's enough weird rules that all.bash doesn't cover everything (maybe it should, but that's a different issue). |
There are many optimizations in amd64.rules that apply to many architectures. As we add architectures, it'd be nice not to repeat discovering and encoding these rules.
To pick an example at random:
(ANDLconst [c] (ANDLconst [d] x)) -> (ANDLconst [c & d] x)
This could probably be done in generic.rules by introducing generic AndNNconst ops.
In some cases, we'd still need the arch-specific rules because optimizable patterns are introduced during lowering. If there are enough of those cases, it might be worth introducing common lowered ops and common lowered optimizations. The best way to find out it to start migrating rules and see.
cc @cherrymui @dr2chase @randall77 @brtzsnr
The text was updated successfully, but these errors were encountered: