[llvm-bugs] [Bug 36158] New: SFINAE in template parameter list is 10x slower than SFINAE in return type
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Jan 30 15:46:57 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=36158
Bug ID: 36158
Summary: SFINAE in template parameter list is 10x slower than
SFINAE in return type
Product: clang
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: eniebler at boost.org
CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
Created attachment 19777
--> https://bugs.llvm.org/attachment.cgi?id=19777&action=edit
demonstrate severe compile-time degradation of SFINAE-in-tparam-list
Please find attached an example where compile times are 10x slower when a
SFINAE condition (std::enable_if) is located in a template parameter list, as
opposed to located in the return type.
Slow code:
template<typename That,
typename std::enable_if<(bool)That(), int>::type = 0>
constexpr friend dummy operator&&(dummy, bool_<That>) noexcept
{
return {};
}
Fast code:
template<typename That>
constexpr friend
typename std::enable_if<(bool)That(), dummy>::type
operator&&(dummy, bool_<That>) noexcept
{
return {};
}
REPRO:
(FAST)
clang++ -std=gnu++11 -DSFINAE_FAST -c sfinae-perf-bug.cpp -o /dev/null
(SLOW)
clang++ -std=gnu++11 -c sfinae-perf-bug.cpp -o /dev/null
On my machine, compiling with SFINAE_FAST defined takes 0.58s, where as without
the define, it takes 5.8s.
By comparison, gcc is also slower for SFINAE-in-template-parameter-list, but
"only" about 60%.
CONTEXT:
The popular range-v3 library makes extensive use of the
SFINAE-in-template-parameter-list to emulate concepts. This perf bug is
probably severely effecting compile times.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180130/8cd15152/attachment.html>
More information about the llvm-bugs
mailing list