This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

lazy execution optimization


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 ?

-- 
Sylvain


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]