Skip to content

[SPIR-V] Env Vulkan 1.1 Validation error: Bad OpSelect instruction produced with optimizations enabled. #8603

Closed
KhronosGroup/SPIRV-Tools
#6827

Description

@NicVanZuylen

Description
Attempting to compile HLSL to SPIR-V with the SPIR-V target environment set as Vulkan 1.1 and optimizations enabled (-O3) will produce invalid SPIR-V with a incorrect OpSelect instruction under certain circumstances.

The following code produces the aforementioned error:

float3 tileColor = { 0.005f, 0.005f, 0.005f };
float  tileBorder = (horizontal == 0) || (vertical == 0) ? 8.0f : 0.0f;

debugRW[pixelCoord.xy].rgba = float4(tileColor.rgb * tileBorder, 0.5f);

With the specific error output in one such test case appearing as:

fatal error: generated SPIR-V is invalid: Expected vector sizes of Result Type and the condition to be equal: Select
  %80 = OpSelect %v3float %79 %33 %34

This may be due to a bugged optimization around the ternary operation when assigning to 'tileBorder' followed by the multiplication of 'tileBorder' with a 3-component vector 'tileColor.rgb'. Judging by the error, the 'OpSelect' op's result type is a float3, whilst 'tileBorder' is a scalar float. The resultant type in this case should be a scalar float, or the arguments for 'OpSelect' should all be 3-component float vectors.

Steps to Reproduce

  1. Checkout and build DXC at SHA: 99400dc80ffa0eb6aef56fc6e482f5eff40185e4 ('main' branch)
  2. Run the built dxc.exe on the following provided HLSL source file in:
    problemhlsl.zip
    with arguments:
    -T cs_6_0 -E csScreenSpaceRaytraceDebug problemhlsl.hlsl -Fo problemshader.spv -spirv -O3 -fspv-target-env=vulkan1.1
  3. Observe output for the aforementioned error.

Actual Behavior
Compilation to SPIR-V will fail with a SPIR-V validation failure.
The error output when running dxc.exe with the above reproduction steps is:

fatal error: generated SPIR-V is invalid: Expected vector sizes of Result Type and the condition to be equal: Select
  %80 = OpSelect %v3float %79 %33 %34

Environment

  • DXC version: dxcompiler.dll: 1.10(5371-99400dc8)(1.10.2605.0) - 1.10.2605.0
  • Host Operating System: Windows 11 24H2 Build 26100.7462
  • Commit SHA: 99400dc80ffa0eb6aef56fc6e482f5eff40185e4

Activity

  1. added
    bug
    spirv
    needs-triage
    on Jul 6, 2026
  2. added a commit that references this issue on Aug 6, 2026
    ec2ba18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugneeds-triagespirv

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions