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 · 1 comment

Comments

Projects
None yet
3 participants
@josharian
Copy link
Contributor

josharian 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

randall77 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

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.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.