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

Replace zero-value constants with OpConstantNull #724

Closed
antiagainst opened this issue Jul 14, 2017 · 3 comments
Closed

Replace zero-value constants with OpConstantNull #724

antiagainst opened this issue Jul 14, 2017 · 3 comments

Comments

@antiagainst
Copy link
Contributor

For example, the following SPIR-V constant:

[[vec:%\d+]] = OpConstantComposite %v4float %float_0 %float_0 %float_0 %float_0
[[mat:%\d+]] = OpConstantComposite %mat2v4float [[vec]] [[vec]]

Can be turned into

[[mat:%\d+]] = OpConstantNull %mat2v4float

Shorter codegen; and I assume the performance should be at least on par?

@dnovillo dnovillo self-assigned this Nov 21, 2017
@dnovillo
Copy link
Contributor

This is folding plus constant propagation.

@dneto0
Copy link
Collaborator

dneto0 commented Nov 23, 2017

One place this can't be done is when that integer is used to index a struct in an access-chain.
However, this is controversial: KhronosGroup/SPIRV-Headers#50

@s-perron
Copy link
Collaborator

There is not great value in doing this. We will not fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants