This is the mail archive of the gcc-patches@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: Warning about unreachable code.


> Date: Tue, 17 Aug 1999 23:57:44 -0700
> From: Richard Henderson <rth@cygnus.com>
> Cc: law@cygnus.com, egcs-patches@gcc.gnu.org
> 
> On Sat, Aug 14, 1999 at 02:56:54AM +1000, Geoff Keating wrote:
> > This patch implements warnings about unreachable code.  It is
> > moderately useful, and would be more so if 'if (0) { foo }' was
> > folded out during RTL generation rather than in cse or flow (this
> > would probably be a small speed win, too).

> Let me guess, this was done at the request of a customer?

I think a customer implemented an earlier version, aimed at C only,
which I rewrote and generalised.

> I think it's nearly useless myself, but it's non-intrusive
> and the implementation is as clean as one could ever ask.

Thank you :-).

One use of it is that in loop.c, line 2873, there is code like this:

if (loc)
{
  ...
  if (loc == 0)
    ...
  ...
}

which gcc cleverly notices and folds out.

Is that code supposed to be unreachable?  The comment says:

                       /* If no suitable BARRIER was found, create a suitable
                          one before TARGET.  Since TARGET is a fall through
                          path, we'll need to insert an jump around our block
                          and a add a BARRIER before TARGET.

                          This creates an extra unconditional jump outside
                          the loop.  However, the benefits of removing rarely
                          executed instructions from inside the loop usually
                          outweighs the cost of the extra unconditional jump
                          outside the loop.  */

but actually we never do this because if we didn't find a BARRIER we
didn't get to this code.

> Ok.

Committed.

-- 
Geoffrey Keating <geoffk@cygnus.com>


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