public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/55213] New: vectorizer ignores __restrict__
@ 2012-11-05 11:51 vincenzo.innocente at cern dot ch
  2012-11-05 12:11 ` [Bug tree-optimization/55213] " jakub at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: vincenzo.innocente at cern dot ch @ 2012-11-05 11:51 UTC (permalink / raw)
  To: gcc-bugs


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55213

             Bug #: 55213
           Summary: vectorizer ignores __restrict__
    Classification: Unclassified
           Product: gcc
           Version: 4.8.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: vincenzo.innocente@cern.ch


I raised this issue before, still I think that with vectorization becoming more
and more common aliasing starts to become an issue for both code-size and
speed.

for all the loops below the compiler emits alias checks.
My desire would be that foo produces optimal code (possibly with much less
__restrict__ in the code than what I used below), 
still even in the others functions __restrict__ is ignored

compiled as
c++ -Ofast -c soa.cc -std=gnu++11 -ftree-vectorizer-verbose=1 -Wall
-march=corei7
with gcc version 4.8.0 20121028 (experimental) [trunk revision 192889] (GCC) 

#include<cstdint>
struct Soa {

  uint32_t * mem;
  uint32_t ns;
  uint32_t cp;
  int const * __restrict__   i() const  __restrict__ { return (int const*
__restrict__)(mem);}
  float const * __restrict__ f() const  __restrict__ { return (float const*
__restrict__)(mem+cp);}
  float const * __restrict__ g() const  __restrict__ { return (float const*
__restrict__)(mem+2*cp);}

};


void foo(Soa const &  __restrict__  soa, float * __restrict__ res) {
  for(std::size_t i=0; i!=soa.ns; ++i)
    res[i] = soa.f()[i]+soa.g()[i];
}

void bar(Soa const & __restrict__ soa, float * __restrict__ res) {
  float const * __restrict__ f = soa.f(); float const * __restrict__ g =
soa.g();
  int n = soa.ns; for(int i=0; i!=n; ++i)
    res[i] = f[i]+g[i];
}


inline
void add(float const * __restrict__ f, float const * __restrict__ g,float *
__restrict__ res,int n) {
  for(int i=0; i!=n; ++i)
    res[i] = f[i]+g[i];
}

void add(Soa const & __restrict__ soa, float * __restrict__ res) {
   add(soa.f(),soa.g(),res,soa.ns);
}


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

end of thread, other threads:[~2012-11-30  7:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-05 11:51 [Bug tree-optimization/55213] New: vectorizer ignores __restrict__ vincenzo.innocente at cern dot ch
2012-11-05 12:11 ` [Bug tree-optimization/55213] " jakub at gcc dot gnu.org
2012-11-05 13:29 ` vincenzo.innocente at cern dot ch
2012-11-20 18:06 ` josh.m.conner at gmail dot com
2012-11-29 22:18 ` josh.m.conner at gmail dot com
2012-11-30  7:45 ` Joost.VandeVondele at mat dot ethz.ch

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).