clang 14 supports target_clones
See https://releases.llvm.org/14.0.0/tools/clang/docs/AttributeReference.html#target-clones
Examples :
- clang 14 : https://godbolt.org/z/GPnd9jYvK
- clang 13 : https://godbolt.org/z/1r4c39q88
- gcc11 : https://godbolt.org/z/KWPqT5vqe
- gcc 8: https://godbolt.org/z/TK6Pd5r5n
Asking explicitly @ssnyder on this.
It seem that clang prefers this on declarations (above doc), while GCC prefers this on definitions. So to use it in both we need to apply to a declaration that is also a definitions.
The inline/header methods in bitscan are fine.
For the other 2 cases I apply it to an Impl
method in an anonymous namespace in the relevant .cxx
where I places the bodies we want to be vectorized.
Edited by Christos Anastopoulos