<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/127512>127512</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[HLSL] Misleading builtin diagnostics
</td>
</tr>
<tr>
<th>Labels</th>
<td>
HLSL
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
llvm-beanz
</td>
</tr>
</table>
<pre>
Many of the HLSL builtins are reporting diagnostics using `err_typecheck_convert_incompatible`, which produces diagnostics of the form:
`error: passing <type1> to parameter of incompatible type <type2>`. This diagnostic strongly implies the usage of the builtin requires a specific type, which is not the case. For example see the `__builtin_hlsl_cross` intrinsic which is valid for 16 and 32-bit floating point types and vectors of such type.
```hlsl
export int4 fn(int4 x, int4 y) {
return __builtin_hlsl_cross(x, y);
}
export int16_t4 fn(int16_t4 x, int16_t4 y) {
return __builtin_hlsl_cross(x, y);
}
```
[Compiler Explorer](https://godbolt.org/z/79hMPMdTT)
Diagnostics:
```
<source>:2:33: error: passing 'int4' (aka 'vector<int, 4>') to parameter of incompatible type '__attribute__((__vector_size__(4 * sizeof(float)))) float' (vector of 4 'float' values)
2 | return __builtin_hlsl_cross(x, y);
| ^
<source>:6:33: error: passing 'int16_t4' (aka 'vector<int16_t, 4>') to parameter of incompatible type '__attribute__((__vector_size__(4 * sizeof(float)))) float' (vector of 4 'float' values)
6 | return __builtin_hlsl_cross(x, y);
| ^
```
These diagnostics strongly indicate to a user that you must call the builtin with a float4.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzUVc2O4zYTfJr2pTGGROrPBx089hjfYQf4gMxdoKi2xSwlKiTlHc_TB6TstSebIAmwlwACLJKqru7qMls4p04jUQ35M-T7lZh9b2yt9Xl4akmMH6vWdJf6VYwXNEf0PeH_vvzyBdtZaa9Gh8ISWpqM9Wo8YafEaTTOK-lwdmEHioSsbfxlItmT_NpIM57J-kaN0gyT8KrVBEUCbIffei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