This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -funswitch-loops not effective?
- From: Richard Guenther <rguenth at tat dot physik dot uni-tuebingen dot de>
- To: gcc at gcc dot gnu dot org
- Date: Mon, 17 Jan 2005 13:25:18 +0100 (CET)
- Subject: Re: -funswitch-loops not effective?
On Mon, 17 Jan 2005, Richard Guenther wrote:
> void foo(int);
> void bar(int);
>
> struct Body {
> Body(bool f) : flag(f) {}
>
> void body(int i) const {
> if (flag)
> foo(i);
> else
> bar(i);
> }
>
> const bool flag;
> };
>
> void foobar(int n, const Body& body)
> {
> for (int i=0; i<n; ++i)
> body.body(i);
> }
Sorry for the noise -- seems to be (again) my misunderstanding
about C++ and const. C++ is appearantly supposed to take body.flag
possibly modified by foo() or bar(). This is also independend of
wether body.flag is public or private. So only passing body by
value helps.
What I don't quite understand is why in the following testcase, unswitching
is happening:
void foo(int);
void bar(int);
extern const _Bool flag;
void foobar(int n)
{
int i;
for (i=0; i<n; ++i)
if (flag)
foo(i);
else
bar(i);
}
likewise, if I declare Body::flag static.
Richard.
--
Richard Guenther <richard dot guenther at uni-tuebingen dot de>
WWW: http://www.tat.physik.uni-tuebingen.de/~rguenth/