[Bug c++/83875] [feature request] target_clones compatible SIMD capability/length check

roland at rschulz dot eu gcc-bugzilla@gcc.gnu.org
Wed Jan 17 06:14:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83875

--- Comment #3 from Roland Schulz <roland at rschulz dot eu> ---
Instead of adding (/modifying) the goal could also be achieved by allowing to
call a target+constexpr function from a target_clone function. Currently this
gives: "error: call to non-constexpr function" (example given below). Note that
calling a target+constexpr function from a target function (with target equal
or higher then highest target) already works (commented out line below). This
suggests that the compiler in this case already understands that if the target
of the caller and callee is the same that it becomes constexpr. But this
analysis doesn't seem to be applied for target_clone.

__attribute__ ((target ("default")))
static inline constexpr int foo() { return 1; }

__attribute__ ((target ("avx2")))
static inline constexpr int foo() { return 2; }

__attribute__((target_clones("avx2","default")))
//__attribute__ ((target ("avx2"))) //if this is used instead, it compiles
int test()
{
    constexpr int i = foo();
    return i;
}

int main()
{
    return test();
}


More information about the Gcc-bugs mailing list