public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tim Hollebeek <tim@hollebeek.com>
To: geoffk@geoffk.org (Geoff Keating)
Cc: aoliva@redhat.com (Alexandre Oliva),
	kenner@vlsi1.ultra.nyu.edu, gcc@gcc.gnu.org,
	dewar@gnat.com (Robert Dewar)
Subject: Re: Bug in loop optimize (invalid postinc to preinc transformation)
Date: Thu, 28 Dec 2000 15:22:00 -0000	[thread overview]
Message-ID: <200012282342.SAA29717@cj44686-b.reston1.va.home.com> (raw)
In-Reply-To: <jm1yusp47z.fsf@geoffk.org>

Geoff Keating writes ...
> 
> Since 0 is not a valid pointer---that is, no pointer to an object
> should ever compare equal to 0---

Please, everyone, be careful with your language.

0 is not a valid pointer because it isn't a pointer.  It's an integral
constant.

Another possible interpretation is that you meant a pointer with
representation all bits zero.  If the null pointer has that
representation, then no valid pointer can have it.  So you're saying
(essentially) is "the all bits zero pointer is the null pointer, which
points to nothing --- no pointer to an object can ever have that
representation".  True, given the assumption that the all bits zero
pointer is the null pointer.

Yet another possible interpretation of '0' in both halves is that
you meant a null pointer constant which is what the integral constant
0 becomes when converted to a pointer.

If that's what you meant then what you said is "a null pointer isn't
non-null --- that is, no non-null pointer should ever compare equal to
a null pointer constant".  True in all cases, but rather unprofound.

No "valid" pointer can compare equal to a null pointer, but this says
nothing about the representation of pointers.  The null pointer need
not be represented by "all bits zero", and all bits zero may be a
valid pointer on some architectures.

> this makes pointers a case of unsigned integers for which overflow
is not permitted.

This doesn't follow at all.

If pointers are implementation as unsigned offsets into a flat memory
model, one of two things is true:

Case 1:
0x00000000 is the null pointer.  Therefore it isn't within a valid
object, and is not immediately following a valid array.  

>>>THEREFORE WRAPPING IS IRRELEVANT<<< since no valid pointer
increment or operation can cross the boundary.

Case 2: 

0x00000000 is within a valid object, or immediately follows an array.
In this case, 0x00000000 cannot be the null pointer, so some other
value (__null) is.  Overflow isn't an issue since if all computations
on unsigned pointer values involve first subtracting __null (using
unsigned arithmetic; wrapping is well defined here) from each pointer,
than adding it back in when necessary, we reduce to case 1.

Either way, wrapping is well-defined/irrelevant.  Optimization must
just preserve the correct semantics.  If an optimization causes values
to be used which might overflow or cause other problems when the
original values would not, then that's a bad optimization.  But this
has nothing to do with "pointer wrapping" or "pointers being unsigned"
or any other such nonsense.  It's just a bad optimization.

  reply	other threads:[~2000-12-28 15:22 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-28  5:40 Robert Dewar
2000-12-28 12:21 ` Alexandre Oliva
2000-12-28 14:32   ` Geoff Keating
2000-12-28 15:22     ` Tim Hollebeek [this message]
2000-12-28 22:20       ` Dave Korn
2000-12-29  0:52         ` Richard Henderson
2000-12-29  1:51         ` Tim Hollebeek
  -- strict thread matches above, loose matches on Subject: below --
2000-12-31  8:30 dewar
2001-01-03  0:52 ` Jamie Lokier
2000-12-29 18:43 dewar
2000-12-30 15:18 ` Toon Moene
2000-12-28 20:33 dewar
2000-12-28  1:14 Richard Kenner
2000-12-27 22:40 Robert Dewar
2000-12-29 18:36 ` Jamie Lokier
2000-12-27  3:04 Bug in loop optimize (TREE stage) David Korn
2000-12-27 15:42 ` Bug in loop optimize (invalid postinc to preinc transformation) Peter Osterlund
2000-12-27 19:55   ` Alexandre Oliva
2000-12-27 21:09     ` Torbjorn Granlund
2000-12-27 21:20       ` Alexandre Oliva
2000-12-27 22:24     ` Jamie Lokier
2000-12-31  8:25       ` Andreas Schwab

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=200012282342.SAA29717@cj44686-b.reston1.va.home.com \
    --to=tim@hollebeek.com \
    --cc=aoliva@redhat.com \
    --cc=dewar@gnat.com \
    --cc=gcc@gcc.gnu.org \
    --cc=geoffk@geoffk.org \
    --cc=kenner@vlsi1.ultra.nyu.edu \
    /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).