public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "wwwhhhyyy333 at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/98176] Loop invariant memory could not be hoisted when nonpure_call in loop body
Date: Tue, 08 Dec 2020 08:29:24 +0000	[thread overview]
Message-ID: <bug-98176-4-9tF6h9si4w@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98176-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #4 from Hongyu Wang <wwwhhhyyy333 at gmail dot com> ---
(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.

> 
> If you replace sincosf with a random call then you'll hit the issue
> that LIMs dependence analysis doesn't handle it at all since it cannot
> represent it.  That will block further optimization in the loop.
> 
> That can possibly be improved.
> 

So could LIMs dependence analysis handle known library function and just
analyze their memory parameter? Random call may have unknown behavior.

> > if (nonpure_call_p (stmt))
> >   {                                        
> >      maybe_never = true; 
> >      outermost = NULL;                      
> >   }
> > 
> > So no store-motion chance for any future statement in such block.
> 
> That's another issue - the call may not return.  Here the granularity
> is per BB and thus loads/stores in the same BB are not considered for
> sinking.
> 

IMHO the condition may be too strict for known library calls.

  parent reply	other threads:[~2020-12-08  8:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-07 13:57 [Bug tree-optimization/98176] New: " 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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-98176-4-9tF6h9si4w@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).