[llvm-bugs] [Bug 31917] New: [feature request] provide a __ctfe builtin for detecting compile-time execution

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Feb 9 04:38:18 PST 2017


https://llvm.org/bugs/show_bug.cgi?id=31917

            Bug ID: 31917
           Summary: [feature request] provide a __ctfe builtin for
                    detecting compile-time execution
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: unassignedclangbugs at nondot.org
          Reporter: gonzalobg88 at gmail.com
                CC: dgregor at apple.com, llvm-bugs at lists.llvm.org
    Classification: Unclassified

>From the D language docs:

"The __ctfe boolean pseudo-variable, which evaluates to true at compile time,
but false at run time, can be used to provide an alternative execution path to
avoid operations which are forbidden at compile time. Every usage of __ctfe is
evaluated before code generation and therefore has no run-time cost, even if no
optimizer is used."

It would be nice to have such an intrinsic in clang to be able to switch
algorithms optimized for compile-time or run-time usage in constexpr functions. 

For example, a constexpr function that wants to use SIMD intrinsics at
run-time, currently cannot, because the intrinsics are not constexpr, and
clang's constant evaluator cannot handle them (and the one in LLVM cannot be
leveraged for this). 

Providing such an intrinsic would be a way easier task than, say, teaching
clang's constant expression evaluator how to handle _all_ intrinsics so that
one can make them constexpr.

-- 
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/20170209/50801c8e/attachment.html>


More information about the llvm-bugs mailing list