Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

[spv-out] ZeroValue expressions produce too many OpConstantNull instructions #2334

Closed
jimblandy opened this issue May 10, 2023 · 2 comments · Fixed by #2414
Closed

[spv-out] ZeroValue expressions produce too many OpConstantNull instructions #2334

jimblandy opened this issue May 10, 2023 · 2 comments · Fixed by #2414
Labels
area: back-end Outputs of shader conversion good first issue Good for newcomers lang: SPIR-V Binary SPIR-V input and output type: enhancement

Comments

@jimblandy
Copy link
Member

#2332 introduces Expression::ZeroValue, which the SPIR-V backend uses to produce OpConstantNull instructions. However, it doesn't check to see if it's already got an an appropriate null constant for the given type, resulting in code like this:

%274 = OpConstantNull %10
%275 = OpConstantNull %10
%276 = OpConstantNull %13
%277 = OpConstantNull %10
%278 = OpConstantNull %8
%279 = OpConstantNull %10
%280 = OpConstantNull %8
%281 = OpConstantNull %10
%282 = OpConstantNull %8
%283 = OpConstantNull %13
%284 = OpConstantNull %8

Only three of these are necessary.

This example appears is in the snapshot output tests/out/spv/bounds-check-image-rzsw.spvasm.

@jimblandy jimblandy added lang: SPIR-V Binary SPIR-V input and output area: back-end Outputs of shader conversion type: enhancement labels May 10, 2023
@teoxoy
Copy link
Member

teoxoy commented May 10, 2023

I think we cache all other constants besides the null variant. This shouldn't be too hard to do considering we have the system in place for it.

@teoxoy teoxoy added the good first issue Good for newcomers label May 10, 2023
@evahop
Copy link
Contributor

evahop commented Jul 25, 2023

I think this is something I didn't catch while doing the composites. I can tackle this

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: back-end Outputs of shader conversion good first issue Good for newcomers lang: SPIR-V Binary SPIR-V input and output type: enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants