This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/21712] missed optimization due with const function and pulling out of loops
- From: "rakdver at atrey dot karlin dot mff dot cuni dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 May 2005 22:31:58 -0000
- Subject: [Bug tree-optimization/21712] missed optimization due with const function and pulling out of loops
- References: <20050522191803.21712.TazForEver@dlfp.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From rakdver at atrey dot karlin dot mff dot cuni dot cz 2005-05-22 22:31 -------
Subject: Re: missed optimization due with const function and pulling out of loops
> > Anyway, moving possibly non-executed const function may cause also
> > other problems. Consider
> >
> > int my_fancy_divide(int x, int z) attribute(const)
> > {
> > return x / z;
> > }
> >
> > while (...)
> > {
> > if (z != 0)
> > x = my_fancy_divide (x,z)
> > }
>
> Uh, this may be const, but you can't move these out anyway because the
> value of the parameters has changed, so i'm not sure what you are going
> for.
I would assume meaning should be clean, once you fix the obvious typo
you noticed.
int my_fancy_divide(int x, int z) attribute(const)
{
return x / z;
}
while (...)
{
if (z != 0)
y = my_fancy_divide (x,z)
}
> const has a very specific definition already. Moving get_type2 out of
> the loop is consistent with that definition.
The definition by no means is formulated precisely, in particular it is
not entirely clear what "reading memory" means.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21712