<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Vector construction of trivial types using const iterator ranges are not optimized like non-const iterator ranges"
href="https://bugs.llvm.org/show_bug.cgi?id=37574">37574</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Vector construction of trivial types using const iterator ranges are not optimized like non-const iterator ranges
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>6.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>All Bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>kjteske@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
</td>
</tr></table>
<p>
<div>
<pre>In <a href="https://reviews.llvm.org/D8109">https://reviews.llvm.org/D8109</a>, vector construction is optimized for trivial
types using an iterator range, i.e. std::vector<int>(int* first, int* last).
However, there is a bug so that const iterators are not optimized as expected,
i.e. std::vector<int>(const int* first, const int* last).
We're not hitting the memcpy overload of __construct_range_forward(). We're
taking the slow overload instead, I believe because 'is_same<allocator_type,
allocator<_Tp> >::value' check on the fast overload passes when _Tp is 'int',
but fails when _Tp is 'const int'.
libstdc++ does optimize the const int* version.
Workaround is to const_cast<> away the const before calling the vector
constructor.
In our application, the workaround improves performance by 4-5x.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>