public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Zack Weinberg <zack@codesourcery.com>
To: Chris Lattner <sabre@nondot.org>
Cc: Tim Hollebeek <tim@hollebeek.com>, gcc@gcc.gnu.org
Subject: Re: pure and const functions
Date: Fri, 30 Aug 2002 23:02:00 -0000	[thread overview]
Message-ID: <20020831060218.GG321@codesourcery.com> (raw)
In-Reply-To: <Pine.LNX.4.30.0204261254150.3330-100000@nondot.org>

On Fri, Apr 26, 2002 at 12:55:51PM -0500, Chris Lattner wrote:
> On Fri, 26 Apr 2002, Zack Weinberg wrote:
> > > Sure, but are there any good examples of a function that would be _useful_
> > > to be marked as pure or const, but which might not return?
> >
> > The examples being kicked around earlier were of routines that were
> > pure except for assertions to enforce data structure integrity.  We
> > would like the compiler to optimize on the basis that the data
> > structure is correct and therefore the pure function will always
> > return.
> 
> Ok, now I'm more confused than before.  :)  When optimizing, do you
> consider it ok for the compiler to drop the assertions in a pure function,
> if it decides to elide the call to the function?

Yes.  Generally this comes up in code of the form

  if (pure_function_which_contains_assertions (structure)
      && expression_which_would_be_provably_false_if_it_had_been_written_first)
    {
      huge block of code which does something with structure
    }

where 'predicate' contains some assertions.  We want GCC to realize
that the entire block is dead code.  Losing the assertions is a minor
price to pay.

zw

  reply	other threads:[~2002-08-30 23:02 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-26 10:17 Chris Lattner
2002-04-26 10:21 ` Kris Warkentin
2002-04-26 10:30   ` Chris Lattner
2002-04-26 10:34     ` Magnus Fromreide
2002-04-26 10:35       ` Chris Lattner
2002-04-26 10:59         ` Magnus Fromreide
2002-04-26 11:03           ` Chris Lattner
2002-04-26 11:27             ` Magnus Fromreide
2002-04-26 12:49           ` Russ Allbery
2002-04-26 10:36     ` Kris Warkentin
2002-04-26 10:46       ` Chris Lattner
2002-04-26 10:26 ` Tim Hollebeek
2002-04-26 10:30   ` Chris Lattner
2002-04-26 10:56     ` Zack Weinberg
2002-04-26 11:01       ` Chris Lattner
2002-08-30 23:02         ` Zack Weinberg [this message]
2002-04-26 10:56     ` Tony Finch
2002-04-26 12:11 ` Mark Mitchell
  -- strict thread matches above, loose matches on Subject: below --
2002-04-29 17:25 John Wehle
2002-04-29  9:29 Robert Dewar
2002-04-29  9:34 ` Chris Lattner
2002-04-29  8:30 Robert Dewar
2002-04-29  8:57 ` Chris Lattner
2002-04-29  8:30 Chris Lattner
2002-04-29  9:23 ` Daniel Berlin
2002-04-29  9:52   ` Chris Lattner
2002-04-29  9:58   ` Mark Dettinger
2002-04-29  5:18 Robert Dewar
2002-04-29  5:44 ` Mark Dettinger
2002-04-29  3:59 Mark Dettinger
2002-04-26  5:16 Mark Dettinger
2002-04-26 11:20 ` Joseph S. Myers
2002-04-26 12:59 ` Jakub Jelinek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20020831060218.GG321@codesourcery.com \
    --to=zack@codesourcery.com \
    --cc=gcc@gcc.gnu.org \
    --cc=sabre@nondot.org \
    --cc=tim@hollebeek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).