public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/98176] New: Loop invariant memory could not be hoisted when nonpure_call in loop body
@ 2020-12-07 13:57 wwwhhhyyy333 at gmail dot com
  2020-12-07 14:18 ` [Bug tree-optimization/98176] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: wwwhhhyyy333 at gmail dot com @ 2020-12-07 13:57 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98176

            Bug ID: 98176
           Summary: Loop invariant memory could not be hoisted when
                    nonpure_call in loop body
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: wwwhhhyyy333 at gmail dot com
  Target Milestone: ---

For testcase

#include <cmath>

void foo(float *x, float tx, float *ret, int n)
{

#pragma omp simd
    for (int i = 0; i < n; i++)
    {
        float s,c;

        sincosf(x[i] * tx, &s, &c);

        *ret += s * c;   
    }
}

It could not be vectorized with -Ofast -fopenmp-simd -std=c++11

https://gcc.godbolt.org/z/ba77az

By manually hoist it could be vectorized with simd clone

void foo(float *x, float tx, float *ret, int n)
{
    float tmp = 0.0f;

#pragma omp simd
    for (int i = 0; i < n; i++)
    {
        float s,c;

        sincosf(x[i] * tx, &s, &c);

        tmp += s*c;      
    }
    *ret += tmp;
}

https://gcc.godbolt.org/z/bea17x

Is it possible for lim to perform store motion on case like this?

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2021-07-08  5:25 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-07 13:57 [Bug tree-optimization/98176] New: Loop invariant memory could not be hoisted when nonpure_call in loop body wwwhhhyyy333 at gmail dot com
2020-12-07 14:18 ` [Bug tree-optimization/98176] " rguenth at gcc dot gnu.org
2020-12-08  2:19 ` wwwhhhyyy333 at gmail dot com
2020-12-08  7:09 ` rguenth at gcc dot gnu.org
2020-12-08  8:29 ` wwwhhhyyy333 at gmail dot com
2020-12-08  9:25 ` rguenth at gcc dot gnu.org
2020-12-08 10:36 ` wwwhhhyyy333 at gmail dot com
2020-12-15  9:13 ` wwwhhhyyy333 at gmail dot com
2021-07-07 12:34 ` rguenth at gcc dot gnu.org
2021-07-08  5:25 ` wwwhhhyyy333 at gmail dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).