Skip to content

Empty if block causes spirv validation errors on spirv 1.6. #7882

@Vecvec

Description

@Vecvec

Description
Translating wgsl with an empty if in the middle of a function generates invalid spirv.

Repro steps
Translate

@workgroup_size(1)
@compute
fn comp(@builtin(global_invocation_id) id: vec3<u32>) {
    if (id.x == 0) {

    }
    _ = 1+1; // otherwise, naga generates returns in the if statement.
    return;
}

into spirv 1.6, then validate it. Demonstrated in https://github.com/Vecvec/wgpu/tree/branch-same-repro.

Expected vs observed behavior
I would expect wgsl that passes validation to also pass spirv validation. This case passes naga validation but not spirv validation

Extra materials

 error: line 25: In SPIR-V 1.6 or later, True Label and False Label must be different labels
  OpBranchConditional %17 %18 %18

Platform
trunk

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions