Skip to content

[HLSL][DirectX] AddUint64 vec4 case resulting in invalid DXIL. #149345

@spall

Description

@spall

https://godbolt.org/z/To9e81PWs

StructuredBuffer<uint4> In : register(t0);
RWStructuredBuffer<uint4> Out : register(u1);

[numthreads(1,1,1)]
void main() {
  Out[3] = AddUint64(In[0], In[0]);
}

This code, when compiled, produces invalid DXIL

# .---command stdout------------
# | Function: main: error: Instructions must be of an allowed type.
# | note: at '%.upto077112 = insertelement <2 x i1> undef, i1 %.elem1, i32 0' in block 'entry' of function 'main'.
# | Function: main: error: Instructions must be of an allowed type.
# | note: at '%58 = insertelement <2 x i1> %.upto077112, i1 %.elem17, i32 1' in block 'entry' of function 'main'.
# | Function: main: error: Instructions must be of an allowed type.
# | note: at '%.i09113 = extractelement <2 x i1> %58, i32 0' in block 'entry' of function 'main'.
# | Function: main: error: Instructions must be of an allowed type.
# | note: at '%.i110114 = extractelement <2 x i1> %58, i32 1' in block 'entry' of function 'main'.
# | Validation failed.
# |
# `-----------------------------
# .---command stderr------------
# | clang-dxc: error: dxv command failed with exit code 1 (use -v to see invocation)
# `-----------------------------
# error: command failed with exit status: 1

These 'insertelement' and 'extractelement' instructions are created by the scalarizer pass, but are unnecessary and could be eliminated.

Metadata

Metadata

Assignees

Labels

Type

Projects

Status

Closed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions