<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/152815>152815</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[HLSL][DirectX] Invalid DXIL when partially assigning to RWStructuredBuffer vector
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kmpeng
</td>
</tr>
</table>
<pre>
https://godbolt.org/z/KPf9YW736
```hlsl
RWStructuredBuffer<uint4> Out : register(u1);
[numthreads(1,1,1)]
void main() {
Out[0].xy = uint2(1, 2); // Only assign first two components
}
```
This code, when compiled, produces invalid DXIL:
```
# .---command stdout------------
# | Function: main: error: Instructions must be of an allowed type.
# | note: at '%.upto23 = insertelement <4 x i32> <i32 1, i32 2, i32 undef, i32 undef>, i32 %3, i32 2' in block 'entry' of function 'main'.
# | Function: main: error: Instructions must be of an allowed type.
# | note: at '%4 = insertelement <4 x i32> %.upto23, i32 %2, i32 3' in block 'entry' of function 'main'.
# | Function: main: error: Instructions must be of an allowed type.
# | note: at '%5 = extractelement <4 x i32> %4, i32 0' in block 'entry' of function 'main'.
# | Function: main: error: Instructions must be of an allowed type.
# | note: at '%6 = extractelement <4 x i32> %4, 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
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVd-P4jYQ_muGlxEosZMAD3mA5VBXXemqXtW7Pjr2BNxzbOQfLPSvrxxgy167rU6VTheBMrE9P77PmvlECHpniVqo11BvJiLFvfPt5-FAdjfpnDq3-xgPAfgK2BbYdudU50ycOb8Dtv0D2PbHn_rlbx_nvIFiBU1x-e1NMFCsfv74IfokY_Kk1qnvyQN_SNrGCvg7fJ8iAl-hp50OkTywRSqBLYGvc6xiBfXapiHuPQkVgC1KYA_X_xLqDRSro9MKB6EtsAWwJcI8u2IODfW6gHozO50R-AZzVnaNgeySBfECCt9bc8YLF9hrHyLGZ4fSDQdnycaQa5lv7gFCsfplrwNKpyhHfN6THR20IZUXDt6pJCmgtkdhtMLNp8enTOPrIMA4zqbTqXTDIKzCEJVLcXr3XA_B_AG3ycqonc2kjaD5Csl757PxaMPItXY24JBCxI7Q9SgsCmPcMymM5wPN7uJZFym7iojA5sDqWTpElzf5BrUN5CMZGsjme3qo8ISas3xzwB80ZzhymQ12M5JV1L_-4O9u38BqfucxR22xM05-ztnJRn_Oi67H_oozr18udz77ljRU_03AC1d34F5Y4N8zuHoER6fohXwbXXXDUnzPWJqvw1L-Dyy_5iYW44Fe5Ca_27xZTTH9t-ef2528f6PdpRF2N1Un-Yo3dTrizf1SCT7ruEc66TiOIywxT9JAOD1idBiI8hBycqw-T76vKvcl8ZtJQxQxZYnA8ovpNlEtV0u-FBNqy3ldNcsFL9hk3_ZdvWiUkl3Nuo4XJZOsnzdy2TSdalRVTXTLClYXi2JZFGVZFbO6kSU1VC4Yr8uqIqgKGoQ2M2OOQ5ajiQ4hUVvWbFHWEyM6MmGUNcYsPeO4C4xllfNtdpp2aRegKowOMfwVJupoRj384enDU1aZer3RnmT8BPUGH--m-WXoH4SPWpgXAdF2l1n_u_ThkWR0fpK8-VJUddynbibdAGybC7m-pgfvficZgW3H8gOw7RXfsWV_BgAA___-_Ufn">