This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] builtins.c, fold-const.c: Don't create type
- From: Steven Bosscher <stevenb at suse dot de>
- To: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- Cc: Paul Schlie <schlie at comcast dot net>, dan at codesourcery dot com, dnovillo at redhat dot com, kazu at cs dot umass dot edu, roger at eyesopen dot com, gcc-patches at gcc dot gnu dot org, sabre at nondot dot org
- Date: Sun, 17 Apr 2005 00:10:22 +0200
- Subject: Re: [patch] builtins.c, fold-const.c: Don't create type
- Organization: SUSE Labs
- References: <200504162133.j3GLXPWw000623@hiauly1.hia.nrc.ca>
On Saturday 16 April 2005 23:33, John David Anglin wrote:
> > > Steven Bosscher
> > >
> > >> On Saturday 16 April 2005 16:36, Roger Sayle wrote:
> > >> Converting "ptr + strlen(ptr)" into "ptr + (char*)strlen(ptr)" in
> > >> builtins.c, just appears a little strange at first sight.
> > >
> > > Why does this appear strange? It just makes the semantics of
> > > pointer addition explicit.
>
> It appears strange. If I encounter this in the backend, the result
> has to be loaded into a register and we probably loose an opportunity
> to do an indexed load or store.
On IRC, Chris Lattner mentioned (if I understood him correctly) that in
LLVM this kind of pointer arithmetic doesn't exist, and that instead it
is converted to "regular" integer arithmatic by casting the pointer to
intptr_t (instead of casting the integer to a pointer). Would that be
a better solution for GCC too, perhaps?
Gr.
Steven