<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61274>61274</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
C compiler unable to perform vectorized ternary operator
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
stolk
</td>
</tr>
</table>
<pre>
Using the latest CLANG compiler, when compiling this snippet **as C**:
```
// Vector with 8 elements of 4 bytes each.
typedef float floatx8 __attribute__( ( vector_size(32) ) );
floatx8 add(floatx8 a, floatx8 b)
{
return a+b;
}
floatx8 min(floatx8 a, floatx8 b)
{
return a < b ? a : b;
}
```
will result in this error:
```
<source>:17:22: error: used type '__attribute__((__vector_size__(8 * sizeof(int)))) int' (vector of 8 'int' values) where arithmetic or pointer type is required
return a < b ? a : b;
~~~~~ ^
1 error generated.
Compiler returned: 1
```
However, **if the exact same code is fed to the C++ compiler**, clang will happily compile those functions into single instruction vector operations on x86-64.
## ACTUAL RESULT
The C compiler [fails](https://godbolt.org/z/hzfc6M9vd).
The C++ compiler [succeeds](https://godbolt.org/z/Ts6GcP7Ys).
## EXPECTED RESULT
Clang treats this code the same both in C and C++ mode.
## Version
clang 15.0.0
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVU9v47YT_TT0ZRBDHtqWfNDBVuz9HfIrFm2yaE8GJY4sthSpklSc5NDPXlCSE68bFIsaEi1qOG_-vHmQ8F6dDFHOVju2up-JPjTW5T5Y_cestPI1f_LKnCA0BFoE8gGKh-1PX6Cybac0OYYFnBsy04vxrPLgjeo6CsBwy3ArPBTjE-Nbltyz5LKuk-kat3hgeIBvVAXr4KxCAxmQppZM8GBrWEL5GsgDiaqZjz7htSNJNdTaijCuLxkcjyIEp8o-0PHIMIN4Pw-4R6_eiGHGkeEGppvx3XVeFxghJcPsfRervWzK6DW6pO--G0ehdyae3JUfmOn9Z-C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