バグのようです: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54408コンポーネントごとに行う以外の回避策はわかりません。いずれにしても、ベクトル拡張は、プラットフォーム固有の組み込み関数を置き換えることを意図したものではありません。
この趣旨のいくつかのファンキーなコード:
#include <cmath>
#include <utility>
template <::std::size_t...> struct indices { };
template <::std::size_t M, ::std::size_t... Is>
struct make_indices : make_indices<M - 1, M - 1, Is...> {};
template <::std::size_t... Is>
struct make_indices<0, Is...> : indices<Is...> {};
typedef float vec_type __attribute__ ((vector_size(4 * sizeof(float))));
template <::std::size_t ...Is>
vec_type sqrt_(vec_type const& v, indices<Is...> const)
{
vec_type r;
::std::initializer_list<int>{(r[Is] = ::std::sqrt(v[Is]), 0)...};
return r;
}
vec_type sqrt(vec_type const& v)
{
return sqrt_(v, make_indices<4>());
}
int main()
{
vec_type v;
return sqrt(v)[0];
}
ベクター拡張とは別の自動ベクター化で運試しをすることもできます。