I think there is currently no direct way and you have to work around it using the syntax you already noticed:
__m256 zero={};
__m256 x=zero+3.14159f;
It may change in the future if we can agree on a good syntax, see PR 55726.
Note that if you want to create a vector { s, s, ... s }
with a non-constant float s
, the technique above only works with integers, or with floats and -fno-signed-zeros
. You can tweak it to __m256 x=s-zero;
and it will work unless you use -frounding-math
. A last version, suggested by Z boson, is __m256 x=(zero+1.f)*s;
which should work in most cases (except possibly with a compiler paranoid about sNaN).