<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/149345>149345</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[HLSL][DirectX]
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
spall
</td>
</tr>
</table>
<pre>
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.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUVV2P4yYU_TXk5SoWYBPbD35IJo060kitutvuvmJzndBiiPjIJPvrKzyZbWa6s9WqUtW1iGID58I5h8uVIei9ReyI2BCxXcgUD8534SiNWfROXbpDjMdAyjXhO8J3e6d6Z2Lh_J7w3SfCd-9diw37-UMgdJ3bil4bXb-LPg0xeVSbNI7oSXmXtI0VKX-AewukXIP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