You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In https://reviews.llvm.org/D8109, vector construction is optimized for trivial types using an iterator range, i.e. std::vector(int* first, int* last). However, there is a bug so that const iterators are not optimized as expected, i.e. std::vector(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.
The text was updated successfully, but these errors were encountered:
Extended Description
In https://reviews.llvm.org/D8109, vector construction is optimized for trivial types using an iterator range, i.e. std::vector(int* first, int* last). However, there is a bug so that const iterators are not optimized as expected, i.e. std::vector(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.
The text was updated successfully, but these errors were encountered: