https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98176
--- Comment #6 from Hongyu Wang <wwwhhhyyy333 at gmail dot com> --- (In reply to Richard Biener from comment #5) > (In reply to Hongyu Wang from comment #4) > > (In reply to Richard Biener from comment #3) > > > > > I see ret[0] has store-motion applied. You don't see it vectorized > > > because GCC doesn't know how to vectorize sincos (or cexpi which is > > > what it lowers it to). > > > > I doubt so, after manually store motion > > > > #include <cmath> > > > > float foo( > > int *x, > > int n, > > float tx > > ) > > { > > float ret[n]; > > float tmp; > > > > #pragma omp simd > > for (int i = 0; i < n; i++) > > { > > float s, c; > > > > sincosf( tx * x[i] , &s, &c ); > > > > tmp += s*c; > > } > > > > ret[0] += tmp; > > > > return ret[0]; > > } > > > > with -Ofast -fopenmp-simd -std=c++11 it could be vectorized to call > > _ZGVbN4vvv_sincosf > > > > ret[0] is moved for sinf() case, but not sincosf() with above options. > > What target are you targeting? Can you provide the sincosf prototype > from your math.h? (please attach preprocessed source). > > I cannot reproduce sincosf _not_ being lowered to cexpif and thus > no longer having memory writes. > I used g++ on godbolt: https://gcc.godbolt.org/z/rv45MK Below extern is sufficient for g++ to vectorize the code __attribute__ ((__simd__ ("notinbranch"))) extern void sincosf (float __x, float *__sinx, float *__cosx); compiled with -Ofast -fopenmp-simd -std=c++11 -march=x86-64