This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: lazy execution optimization
- To: Sylvain Pion <Sylvain dot Pion at sophia dot inria dot fr>
- Subject: Re: lazy execution optimization
- From: "Steven W. Orr" <steveo at world dot std dot com>
- Date: Sun, 26 Sep 1999 18:14:49 -0400 (EDT)
- cc: gcc at gcc dot gnu dot org
- Reply-To: steveo at world dot std dot com
I'm definitely not a qualified person to answer this, but have you tried
the following construct to see if the outcome is affected:
int f (double a, double b)
{
double c;
c = a+b;
if (a > 0.0)
return 0;
else if (c > 0.0)
return 1;
else
return 2;
}
I'm just speculating that maybe this in conjunction with -O2 might just
reorder in a better way.
--
-Time flies like the wind. Fruit flies like a banana. steveo@world.std.com-
-Stranger things have happened but none stranger than this. Steven W. Orr-
Does your driver's license say Organ Donor?Black holes are where God \
-------divided by zero. Listen to me! We are all individuals!---------
On Sun, 26 Sep 1999, Sylvain Pion wrote:
=>Let's consider the following function:
=>
=>int f (double a, double b)
=>{
=> double c;
=> c = a+b;
=> if (a > 0.0) return 0;
=> if (c > 0.0) return 1;
=> return 2;
=>}
=>
=>I would like GCC to optimize it by computing "c" only after the first test,
=>just as if the code was:
=>
=>int f (double a, double b)
=>{
=> double c;
=> if (a > 0.0) return 0;
=> c = a+b;
=> if (c > 0.0) return 1;
=> return 2;
=>}
=>
=>It seems 2.95.1 as well as the current CVS do not perform such an
=>optimization.
=>
=>Would it be reasonnable and possible ?
=>
=>