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: unassignedclangb...@nondot.org
          Reporter: enieb...@boost.org
                CC: dgre...@apple.com, llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to