microsoft / microsoft/DirectXShaderCompiler

[SPIR-V] DXC emits OpLogicalAnd on an invalid type of array of bool vectors

Open
#8,129 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug spirv
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Description
Compiling an HLSL compute shader to SPIR-V fails with invalid SPIR-V for a logical-and (&&) involving boolean vector data. The generated SPIR-V contains an OpLogicalAnd whose Result Type is an array of boolean vectors, but OpLogicalAnd requires a bool scalar or a bool vector result type. DXC then aborts with a SPIR-V validity error.

Steps to Reproduce

<dxc_build_dir>/bin/dxc-3.7 \
  -spirv -fspv-target-env=vulkan1.3 -T cs_6_0 \
  -Fo matrix_bool_and_operator.test.tmp.o \
  matrix_bool_and_operator.test.tmp/source.hlsl

Actual Behavior
DXC terminates with the following error:

fatal error: generated SPIR-V is invalid: Expected bool scalar or vector type as Result Type: LogicalAnd
  %103 = OpLogicalAnd %_arr_v3bool_uint_2 %70 %70

Environment

dxc-3.7 --version
libdxcompiler.dylib: 1.9(dev;5025-eaf198f6); libdxil.dylib: 1.9

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Compiler Explorer repro or run the provided dxc command against the HLSL input, then inspect the generated SPIR-V around the OpLogicalAnd instruction. Done means compiling the repro no longer produces an invalid result type and DXC passes SPIR-V validation.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.