This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: don't generate dead bytecode
- From: Bryce McKinlay <bryce at waitaki dot otago dot ac dot nz>
- To: Per Bothner <per at bothner dot com>
- Cc: tromey at redhat dot com, Gcc Patch List <gcc-patches at gcc dot gnu dot org>, Java Patch List <java-patches at gcc dot gnu dot org>, Alexandre Petit-Bianco <apbianco at cygnus dot com>
- Date: Tue, 20 Nov 2001 21:54:56 +1300
- Subject: Re: Patch: don't generate dead bytecode
- References: <87elocq19k.fsf@creche.redhat.com> <3BC39195.6040803@bothner.com> <3BC3990B.3000000@bothner.com> <3BC62CED.1080903@bothner.com> <87u1x5lejy.fsf@creche.redhat.com> <3BC78628.7080809@bothner.com> <87bshz2pg0.fsf@creche.redhat.com> <3BF8B29D.5040907@bothner.com>
Per Bothner wrote:
> Folding a binary operator when both operand are constants is presumably
> safe - or are the some traps I'm not aware of?
Here's a case which we get wrong with -O. Note that if x and y are not
constant, it works correctly.
public class PR4822
{
public static void main(String[] args)
{
int x = 99;
int y = 0;
if ((x = y) == (99 - (y = 99)))
System.out.println ("OK");
else
System.out.println ("FAIL");
}
}
regards
Bryce.