[Bug tree-optimization/98176] Loop invariant memory could not be hoisted when nonpure_call in loop body
wwwhhhyyy333 at gmail dot com
gcc-bugzilla@gcc.gnu.org
Tue Dec 8 10:36:36 GMT 2020
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
More information about the Gcc-bugs
mailing list