This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch tree-optimization]: Improve handling of conditional-branches on targets with high branch costs
Hi,
On Wed, 26 Oct 2011, Kai Tietz wrote:
> >> > int f(char *i, int j)
> >> > {
> >> > Â Â Â Âif (*i && j!=2)
> >> > Â Â Â Â Â Â Â Âreturn *i;
> >> > Â Â Â Âelse
> >> > Â Â Â Â Â Â Â Âreturn j;
> >> > }
> >>
>
> the case can be produced quite easily.
>
> extern int global = 0;
>
> ....
> if (*a && global) ...
See? You had to change the program to prove the transformation to be
invalid. But my point was that the function we discuss about was exactly
as above. It didn't have globals, or two loads, or a volatile, or
anything else you can come up with where the transformation would be
detectable (and hence invalid). I claim that you can't construct a
program that can distinguish between this function:
int f(char *i, int j)
{
Âif (*i && j!=2)
 Âreturn *i;
Âelse
 Âreturn j;
}
and this one:
int f(char *i, int j)
{
Âif (*i & j!=2)
 Âreturn *i;
Âelse
 Âreturn j;
}
And if you can't construct such a program, then the initial transformation
before the fold-const.c change _for this specific situation_ was correct.
Ciao,
Michael.