This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RE: [PING] [PATCH] _Cilk_for for C and C++
- From: "Iyer, Balaji V" <balaji dot v dot iyer at intel dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: 'Jason Merrill' <jason at redhat dot com>, 'Jeff Law' <law at redhat dot com>, "'Aldy Hernandez'" <aldyh at redhat dot com>, "'gcc-patches at gcc dot gnu dot org'" <gcc-patches at gcc dot gnu dot org>, "'rth at redhat dot com'" <rth at redhat dot com>
- Date: Wed, 12 Feb 2014 17:04:38 +0000
- Subject: RE: [PING] [PATCH] _Cilk_for for C and C++
- Authentication-results: sourceware.org; auth=none
- References: <20140129113129 dot GT892 at tucnak dot redhat dot com> <BF230D13CA30DD48930C31D4099330003A4CC12A at FMSMSX101 dot amr dot corp dot intel dot com> <20140207140233 dot GA3184 at laptop dot redhat dot com> <BF230D13CA30DD48930C31D4099330003A4CCC35 at FMSMSX101 dot amr dot corp dot intel dot com> <20140207145301 dot GE2764 at laptop dot redhat dot com> <BF230D13CA30DD48930C31D4099330003A4CCDA4 at FMSMSX101 dot amr dot corp dot intel dot com> <20140210175731 dot GL20378 at tucnak dot redhat dot com> <BF230D13CA30DD48930C31D4099330003A4CD72B at FMSMSX101 dot amr dot corp dot intel dot com> <20140212145913 dot GM20378 at tucnak dot redhat dot com> <BF230D13CA30DD48930C31D4099330003A4CDF8D at FMSMSX101 dot amr dot corp dot intel dot com> <20140212152851 dot GN20378 at tucnak dot redhat dot com>
> > > More importantly, what is retval.1? I'd expect you should be using
> > > retval.0 there and have it also as firstprivate(retval.0) on the parallel.
> > > In *.omplower dump I actually see:
> > > retval.0 = operator-<int> (D.2885, &i); ...
> > > retval.1 = operator-<int> (D.2888, &i);
> > > i.e. operator-<int> is called twice.
> > >
> >
> > Yes, one is for the if-clause and one is for the condition. It really doesn't
> matter because we get of the stuff in the condition and replace with our own
> for loop with something like the for-loop shown below. So retval1 doesn't
> come into picture. It is only alive from parser to the expand_cilk_for function.
> >
> > For (i = low; i < high; i++)
> > {
> > <_Cilk_for_body>
> > }
>
> No, it really does matter. Just look at the *.optimized dump with -O0 -
> fcilkplus:
>
> retval.0_4 = operator-<int> (_3, &i);
> in _Z3foo1JIiE function and
> _4 = .omp_data_i_2(D)->j;
> _5 = J<int>::end (_4);
> retval.1_6 = operator-<int> (_5, &i);
> retval.3_7 = retval.1_6;
> in _Z3foo1JIiE._cilk_for_fn.0. All the 4 statements are dead, you really
> shouldn't emit them, even when optimizing, if e.g. the operator- isn't inline,
> g++ won't be able to optimize it away.
>
I looked at the test code you send me (cf3.cc) at -O1 and it is removing all the lines you have shown above. Yes, I would imagine -O0 to have code that can be redundant or unnecessary. Some of it could be the artifact of internal code insertion. But isn't the main job of the instruction scheduler to remove all these redundant work? Besides, it is just a function call. The compiler at -O2, -O and -O3 removes the chunk of code that you mentioned.
-Balaji V. Iyer.
> Jakub