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

Comments

Projects
None yet
4 participants
@josharian
Copy link
Contributor

commented Mar 13, 2019

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

This comment has been minimized.

Copy link
Contributor

commented Mar 13, 2019

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.

@josharian josharian added NeedsFix and removed NeedsDecision labels Mar 14, 2019

@josharian

This comment has been minimized.

Copy link
Contributor Author

commented Mar 22, 2019

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

@mvdan

This comment has been minimized.

Copy link
Member

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
You can’t perform that action at this time.