-
Notifications
You must be signed in to change notification settings - Fork 831
Fix isGenerative on calls and test via improving OptimizeInstructions::areConsecutiveInputsEqual() #6481
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
Conversation
src/ir/properties.cpp
Outdated
| struct Scanner : public PostWalker<Scanner> { | ||
| bool generative = false; | ||
|
|
||
| void visitCall(Call* curr) { generative = true; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we see if the callee has side effects here? If it doesn't, then it must be pure and we know it can't be generative. (Unless we're missing generativity itself as a side effect?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point that we could do better here, I'll add a TODO. Effects are not enough, though: imagine the body is a struct.new, that has no effects but it is generative. So we'd need to recursively check the generativity property.
| )) | ||
|
|
||
| ;; But generative effects in the fallthrough values themselves block us. | ||
| (drop (f64.abs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to put each of these cases in its own function so that it appears adjacent to its output in the test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| (call $set-i32 | ||
| (i32.const 1337) | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does the code do the right thing if this is a local.set $x so the "matching" tee and get are not matching after all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, that was wrong. Fixed now and added testing.
tlively
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
"Generative" is what we call something like a
struct.newthat may be syntacticallyidentical to another
struct.new, but each time a new value is generated. The sameis true for calls, which can do anything, including return a different value for
syntactically identical calls.
This was not a bug because the main user of
isGenerative,areConsecutiveInputsEqual(), was too weak to notice, that is, it gave up sooner,for other reasons. This PR improves that function to do a much better check,
which makes the fix necessary to prevent regressions.
This is not terribly important for itself, but will help a later PR that will add code
that depends more heavily on
areConsecutiveInputsEqual().