Hello Marc, Please see my response below. Thanks for looking at my patch!
Sincerely, Balaji V. Iyer. >-----Original Message----- >From: Marc Glisse [mailto:marc.gli...@inria.fr] >Sent: Thursday, September 06, 2012 2:06 AM >To: Gabriel Dos Reis >Cc: Iyer, Balaji V; gcc-patches@gcc.gnu.org; Aldy Hernandez >(al...@redhat.com); Jeff Law; r...@redhat.com >Subject: Re: [PATCH] Merging Cilk Plus into Trunk (Patch 1 of approximately 22) > >On Wed, 5 Sep 2012, Gabriel Dos Reis wrote: > >> On Wed, Sep 5, 2012 at 5:09 PM, Iyer, Balaji V <balaji.v.i...@intel.com> >> wrote: >>> Let's say we have two for loops like this: >>> >>> int my_func (int x, int y); >>> >>> For (ii = 0; ii < 10000; ii++) >>> X[ii] = my_func (Y[ii], Z[ii]); > >I assume X, Y and Z are __restrict pointers (or something the compiler can >detect >doesn't alias). Yes, the compiler must detect that. > >> 2. Considering this example, won't you get the same behaviour >> if my_func was declared with "pure" attribute? If not, why? > >AFAIU, my_func is defined in a separate library and because of the attribute on >the definition, it will actually export overloads: >int myfunc(int,int); >v2si myfunc(v2si,v2si); >v4si myfunc(v4si,v4si); >etc (where does it stop? seems problematic if the library is compiled for >sse4 and I then compile and link an avx program) The user can provide at most 1 vector length and the compiler will map it to appropriate vector value. If the user omits the vectorlength clause then the compiler picks a vectorlength based on the architecture's vector units and the data width. So, it will stop at 2 (1 scalar and 1 vector) :-). > >(hopefully with implementations more clever than breaking the vectors into >pieces and calling the basic myfunc on each) > >The attribute on the declaration then lets gcc's vectorizer know it can call >those >overloads. > >With suitable pure/const attribute you could unroll the loop a bit and reorder >the >calls to myfunc, but without myfunc's body, you couldn't do as much. > >Note that this is my guess from reading the example and completely ignoring the >patch, it could be miles from the truth, and it needs better explanation (the >doc >patch is coming later in the series IIRC). > >-- >Marc Glisse