<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 - The performance of some vector operator is worse than GCC"
   href="https://bugs.llvm.org/show_bug.cgi?id=49324">49324</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The performance of some vector operator is worse than GCC
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>8.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows NT
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </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>499537630@qq.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=24563" name="attach_24563" title="testcase">attachment 24563</a> <a href="attachment.cgi?id=24563&action=edit" title="testcase">[details]</a></span>
testcase

clang++ -O2 test.cpp
./a,out

g++ -O2 test.cpp
./a.out

clang++ -v
clang version 8.0.1  (based on LLVM 8.0.1)

g++ -v
gcc version 7.3.0

result for example:
test                                             clangxxO2/gxxO2
test_int8_t[data5(data.begin(), data.end())]          13.03
test_int8_t[data1.assign(100000000, 100)]             9.58 
test_int8_t[data7.assign(data.begin(), data.end())]   18.81 

We have other operator worse than GCC, like map and unordered_set.

For vector assign, the main function consumed is __construct_range_forward.
libcxx use the  __construct_range_forward 
Each element is constructed using the construct method, which is constructed
using the placement new method. GCC uses std::uninitialized_copy to copy the
memory. The performance is significantly better than that of libcxx.
see: <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - The performance of vector::assign is 100 times worse than that of libstdc++."
   href="show_bug.cgi?id=48893">https://bugs.llvm.org/show_bug.cgi?id=48893</a>#add_comment</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>