-
Notifications
You must be signed in to change notification settings - Fork 569
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
spirv-opt: fix copy-propagate-arrays index opti on structs. #4891
Conversation
result->GetMember(components); | ||
return result; | ||
if (!result) { | ||
return nullptr; |
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 change putting this fisrt.
907d042
to
1d91d65
Compare
Copy-propagate-arrays optimization pass would create unused constants, even if the optimization not completed. This was caused by the way we handled OpAccessChain squashing: we only referenced constants, and had to create them upfront. Signed-off-by: Nathan Gauër <brioche@google.com>
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.
Looks goot. Just a minor nit. The array size in the comment.
As per SPIR-V spec: OpAccessChain indices must be OpConstant when indexing into a structure. This optimization tried to remove load cascade. But in some scenario failed: ```c cbuffer MyStruct { uint my_field; }; uint main(uint index) { const uint my_array[1] = { my_field }; return my_array[index] } ``` This is valid as the struct is indexed with a constant index, and then the array is indexed using a dynamic index. The optimization would consider the local array to be useless and generated a load directly into the struct. Fixes KhronosGroup#4887 Signed-off-by: Nathan Gauër <brioche@google.com>
Looks good, but do not merge until Kokoro runs the presubmits. It seems to be slow today. |
Thanks for the review! |
I don't think the tests ran. When they run, there are 20 checks. This only has 2. Edit: I check the continuous build, and it does not look like anything is failing. |
Copy-propagate-arrays optimization pass would create unused constants,
even if the optimization not completed.
This was caused by the way we handled OpAccessChain squashing: we
only referenced constants, and had to create them upfront.
For now, I couldn't find a path to reproduce this. (Might have one involving RuntimeArrays, but couldn't generate one).
This however will be more visible once #4887 is fixed since we would need to abort while computing the final OpAccessChain.
Signed-off-by: Nathan Gauër brioche@google.com