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

spirv-opt: Loop unroller removes RelaxedPrecision decorations #5902

Open
castano opened this issue Dec 4, 2024 · 0 comments
Open

spirv-opt: Loop unroller removes RelaxedPrecision decorations #5902

castano opened this issue Dec 4, 2024 · 0 comments

Comments

@castano
Copy link

castano commented Dec 4, 2024

When you have a loop that has instructions with RelaxedPrecision decorations, unrolling it maintains the RelaxedPrecision decoration in the first copy of the loop, but removes it from the remaining ones.

For example, in a loop like this:

    [[unroll]] for (uint i = 0; i < 16; i++) {
        mediump float x = inputData[idx * 16 + i] * 16 - sum;
        var += x * x;
    }

The result is as follows:

    float _69 = (_34.inputData[_38] * 16.0) - _523;
    mediump float mp_copy_69 = _69;
    float _102 = (_34.inputData[_338] * 16.0) - _523;
    float _118 = (_34.inputData[_351] * 16.0) - _523;
    float _134 = (_34.inputData[_364] * 16.0) - _523;
    float _150 = (_34.inputData[_377] * 16.0) - _523;
    ...

This results in a significant performance degradation on shaders using mediump/min16float types.

Full example attached: unroll.zip

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

No branches or pull requests

1 participant