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]

Re: turning throw into a jump


On Mon, Jul 23, 2001 at 05:18:24PM -0700, Richard Henderson wrote:
> > I noticed that throw() seems slower with GCC 3.0 rather than 2.95 :(
> > I wonder if it would be possible to turn a throw() which is local inside a
> > try{} block (including after inlining) into a simple jump, which would make
> > it much faster...  Maybe something else also useful would be get rid of the
> > whole exception code when the compiler can show that the code inside a try
> > block cannot throw.  Is this doable ?
> 
> Not only doable, but all of what you suggest is already done.

???  What I was talking about is the following program, for example, for which
I would expect f() to be optimized to an empty function like g().  Running it
with GCC 3.0 on i686-linux with -O2 or -O3 clearly shows that it is not
optimized the same.  Are there special -f* options to enable these
optimizations ?  What did I miss ?


void f()
{
  try
  {
    throw int();
  }
  catch (int i)
  {
  }
}

void g()
{
}

int main()
{
  for (int i=0; i<1000000 ; i++)
    f();
    // g();
}

-- 
Sylvain


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