common branch conditions - could optimize better

Jeffrey A Law law@cygnus.com
Thu Dec 16 01:15:00 GMT 1999


  In message <Pine.LNX.4.10.9910160739260.1293-100000@first>you write:
  > Hello GCC people
  > 
  > Consider the following code:
  > 
  > void f1(void), f2(void), f3(void);
  > void foo (int x, int y)
  > {
  >     if (x*x*x<y*y)
  > 	f1();
  >     else
  > 	f2();
  >     if (x*x*x<y*y)
  > 	f3();
  > }
  > 
  > Here the condition x*x*x<y*y could be tested only once.
  > GCC 2.95.1 does not optimize this - see below the asm,
  > produced with gcc -O2 -S on i586-linux.
  > Even x*x*x and y*y are computed twice... what is that gcse thing then?
It's got to be something goofy about the ia32 target, they're removed just
fine on my PA target.

jeff



More information about the Gcc mailing list