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]
Other format: [Raw text]

Re: [PATCH] Fix PR24851 (2nd version)


Richard Guenther <rguenther@suse.de> writes:

> On Tue, 15 Nov 2005, Richard Guenther wrote:
> 
> > I have a patch along Andrews that fixes both testcases.  I'll post it as
> > soon as testing finishes.
> 
> Here it is.  It fixes fold and fold_stmt to use signed division in
> recombining pointer + offset to an ARRAY_REF.  I'm not sure this is
> a correct fix, but it passes bootstrap and regtesting (32 and 64 bit)
> on x86_64-unknown-linux-gnu for all default languages.

It seems to me that this is a small problem with our representation.
p[-1] where p is a pointer ought to be represented as a pointer plus a
signed value.  p[0xffffffff] ought to be represented as a pointer plus
an unsigned value.  Right now both cases are represented as a pointer
plus an unsigned value, because we want PLUS_EXPR to use the same type
for both operands, and pointers are treated as an unsigned type.

> 2005-11-15  Richard Guenther  <rguenther@suse.de>
> 
> 	PR middle-end/24851
> 	* fold-const.c (try_move_mult_to_index): Make sure to
> 	use a signed division for ptr-offset / element-size.
> 	* tree-ssa-ccp.c (maybe_fold_offset_to_array_ref): Likewise.
> 
> 	* gcc.c-torture/execute/pr24851.c: New testcase.

I think this is OK.  It basically assumes that pointer offsets are
signed, which seems like a reasonable assumption.

Please give it 24 hours to see if anybody else has a comment.

Thakns.

Ian


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