<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/66577>66577</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
`std::set<std::string>::count()` is more expensive with `libc++`
</td>
</tr>
<tr>
<th>Labels</th>
<td>
libc++
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
firewave
</td>
</tr>
</table>
<pre>
```cpp
#include <set>
#include <string>
int f(const std::set<std::string>& s)
{
return s.count("s");
}
```
libstdc++
```
Iterations: 100
Instructions: 8100
Total Cycles: 6970
Total uOps: 9700
Dispatch Width: 4
uOps Per Cycle: 1.39
IPC: 1.16
Block RThroughput: 24.3
```
libc++
```
Iterations: 100
Instructions: 9500
Total Cycles: 8868
Total uOps: 12300
Dispatch Width: 4
uOps Per Cycle: 1.39
IPC: 1.07
Block RThroughput: 30.8
```
https://godbolt.org/z/WbGETxbqs
If you use a different type like `int` then `libc++` is actually faster: https://godbolt.org/z/b9KKnrTjP
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyslE1v6ygUhn8N3qBaGOKvhRf5aEZVF1ONInWN8XFMS4wHDm0zv35kx23Se3vTu7gI2cDLOX7PI_lI7_W-B6hIuiLpJpIBO-uqVjt4lS8Q1bY5ViRjp6mGgbANYUvChe6VCQ1QItYekIjbLxV0ut-fxempe6Qt4YWyvUfqsSFiScRyyrI-bz9CeUY94eWcIl-dFpRS6gCD66mPlQ09El4Qzj3hfLwtVu8Bm3nxXsWlF6Nrj40ifDXOr-7dITiJ2vaeiCVN2Ptx79EF9SFMo_iQdxaloeujMnCWszL_JIe_h0ksc_bJ1Eb7QaLq6KNusJvDFydtjKEP4E65Zy2JxYzn7mE92YyT7HSwMlY90392nbNh3w0BR5kvYnEdyu8TmccvwZTpVSZFkRVfMUm4-PNQWH4FimBxcQVKhzg5I3xL-HZvm9oajK3bE779j_DtY_3X7e6t_tdfBt219GgDDR6opI1uW3DQI8XjANToZ6AkY7pHkjGKHfTj9gJ-xqj2VCoM0pgjbaVHcKPV77zU5f1973ZPD1FTiaYUpYygSrJyUeSC50XUVY1UadLmIGSRFqliRZotlEgLUEXOGt5GuuKMC1YmWbJgeZrFNRNNmdRJmaRtBhzIgsFBahMb83IYvx1p7wNUWZbmeWRkDcZPXYXzi5I4H7uMq8agmzrsPVkwoz36cxrUaGDsOd93hml7_vfLmdjBOqDwNkDv9QvQV43dT2Sj4Ez1A0eNXahjZQ-Eb0c78-tmcPYJFBK-nUr0hG-nKv8PAAD__-XkeK0">