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: allow ; on the RHS of rewrite rules for side-effects #30818

Open
josharian opened this issue Mar 13, 2019 · 3 comments
Open

cmd/compile: allow ; on the RHS of rewrite rules for side-effects #30818

josharian opened this issue Mar 13, 2019 · 3 comments
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@josharian
Copy link
Contributor

Consider this rewrite rule:

(ADDQ x l:(MOVQload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) && clobber(l) -> (ADDQload x [off] {sym} ptr mem)

The canMergeLoadClobber condition is pure (free from side-effects). The clobber condition is not really a condition at all, but pretends to be one and is there for side-effects instead.

It'd be nice, for both clarity and reusability, to be able to put side-effects on the RHS of the rule. Something like:

(ADDQ x l:(MOVQload [off] {sym} ptr mem)) && canMergeLoadClobber(v, l, x) -> clobber(l); (ADDQload x [off] {sym} ptr mem)

noteRule, warnRule, and clobberIfDead all belong on the RHS.

@mundaym's hypothetical mergeSuccessor function could also be naturally split into pure conditional LHS and impure RHS.

Thoughts?

cc @randall77 @cherrymui @mvdan @mundaym

@randall77
Copy link
Contributor

Sure, I like it.
It's a little bit strange that in A; B A is a Go statement and B is an s-expression. But I'm ok with that.

@ALTree ALTree added the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Mar 14, 2019
@josharian josharian added NeedsFix The path to resolution is known, but the work has not been done. and removed NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Mar 14, 2019
@josharian
Copy link
Contributor Author

This is waiting on a decision on #30810. (I don't want to implement twice.)

@mvdan
Copy link
Member

mvdan commented Mar 22, 2019

I think both should happen, and I think this would be easier to implement with #30810 done :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants