Use deep effects in areConsecutiveInputsEqual#8808
Conversation
Although it is true that side effects in the children of the LHS input affect both the LHS and RHS inputs equally, we did not properly account for the fact that the same effects are executed again as part of the RHS and can change its value.
| // Does the left-hand parent expression or side effects in the right-hand | ||
| // children affect the values flowing into the right-hand parent expression? |
There was a problem hiding this comment.
This sounds a little confusing to me. What does "left-hand parent expression or side effects in the right-hand children" mean? I think what we want to ensure is LHS parent + LHS children should not affect RHS children, right?
Also even though technically LHS and RHS are the same here, it would be nice to comment that, because we just computed RHS effects above and are saying LHS effects here.
There was a problem hiding this comment.
This sounds a little confusing to me. What does "left-hand parent expression or side effects in the right-hand children" mean? I think what we want to ensure is LHS parent + LHS children should not affect RHS children, right?
But it's not the execution LHS children that causes the RHS to have a different value from the LHS, it's the execution of the RHS children (or possibly the LHS parent expression).
There was a problem hiding this comment.
What I meant by the LHS children were the parameters for the LHS function, and LHS parent was the LHS function execution itself. Did you mean that too?
Then, wasn't it the LHS children's execution (which increased the global's value) that causes RHS's parameters (childrens) to have different values? Maybe we are talking about the same thing with a slightly different terms.
There was a problem hiding this comment.
What I meant by the LHS children were the parameters for the LHS function, and LHS parent was the LHS function execution itself. Did you mean that too
Yes 👍
Then, wasn't it the LHS children's execution (which increased the global's value) that causes RHS's parameters (childrens) to have different values? Maybe we are talking about the same thing with a slightly different terms.
No, because the LHS children execute before the LHS function call, so their side effects are already visible in the final LHS value. It's those same child expressions executing on the RHS before the RHS function call that make the RHS value different from the LHS value.
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| ;; CHECK-NEXT: ) | ||
| (func $function-effects-interfere (result f32) |
There was a problem hiding this comment.
Maybe some comments on why this shouldn't be optimized?
Although it is true that side effects in the children of the LHS input affect both the LHS and RHS inputs equally, we did not properly account for the fact that the same effects are executed again as part of the RHS and can change its value.