Skip to content

spirv-opt: Loop unroller doesn't support OpConstantNull #3634

@Vasniktel

Description

@Vasniktel

shader.txt

If you try to execute spirv-opt <attached file> -o out.spv --loop-unroll on the attached file, the tool will crash. The reason is that LoopUnroller optimization pass doesn't support OpConstantNull instructions.

Note that the attached file demonstrates the case when the initial value of the counter

is an OpConstantNull. The same bug can be observed if we try to use OpConstantNull to limit the number of iterations or as a step of an iteration (ids %7, %13, %21 in the attached file).

The code that causes these crashes is as follows.

const analysis::Integer* type =
upper_bound->AsIntConstant()->type()->AsInteger();

const analysis::Integer* step_type =
step_constant->AsIntConstant()->type()->AsInteger();

const analysis::Integer* type =
constant->AsIntConstant()->type()->AsInteger();

Can be reproduced on b78f4b1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions