emit-rtl.c (adjust_address_1): Reduce offset to a signed value that fits within Pmode.

* emit-rtl.c (adjust_address_1): Reduce offset to a signed value
	that fits within Pmode.

testsuite:
	* gcc.c-torture/compile/20090303-1.c,
	gcc.c-torture/compile/20090303-2.c: New tests.

From-SVN: r144595
This commit is contained in:
Joseph Myers 2009-03-04 01:57:29 +00:00 committed by Joseph Myers
parent dd7d0a4f8f
commit a6fe9ed43e
5 changed files with 61 additions and 0 deletions

View File

@ -1,3 +1,8 @@
2009-03-03 Joseph Myers <joseph@codesourcery.com>
* emit-rtl.c (adjust_address_1): Reduce offset to a signed value
that fits within Pmode.
2009-03-03 Steve Ellcey <sje@cup.hp.com>
PR middle-end/10109

View File

@ -2008,6 +2008,7 @@ adjust_address_1 (rtx memref, enum machine_mode mode, HOST_WIDE_INT offset,
rtx memoffset = MEM_OFFSET (memref);
rtx size = 0;
unsigned int memalign = MEM_ALIGN (memref);
int pbits;
/* If there are no changes, just return the original memory reference. */
if (mode == GET_MODE (memref) && !offset
@ -2019,6 +2020,16 @@ adjust_address_1 (rtx memref, enum machine_mode mode, HOST_WIDE_INT offset,
(plus (plus reg reg) const_int) -- so do this always. */
addr = copy_rtx (addr);
/* Convert a possibly large offset to a signed value within the
range of the target address space. */
pbits = GET_MODE_BITSIZE (Pmode);
if (HOST_BITS_PER_WIDE_INT > pbits)
{
int shift = HOST_BITS_PER_WIDE_INT - pbits;
offset = (((HOST_WIDE_INT) ((unsigned HOST_WIDE_INT) offset << shift))
>> shift);
}
if (adjust)
{
/* If MEMREF is a LO_SUM and the offset is within the alignment of the

View File

@ -1,3 +1,8 @@
2009-03-03 Joseph Myers <joseph@codesourcery.com>
* gcc.c-torture/compile/20090303-1.c,
gcc.c-torture/compile/20090303-2.c: New tests.
2009-03-03 Jakub Jelinek <jakub@redhat.com>
PR fortran/39354

View File

@ -0,0 +1,20 @@
/* The array offset became 0x1ffffffffffffffe via a conversion from
signed to unsigned HOST_WIDE_INT, causing an ICE compiling for
Thumb. */
int r (unsigned short *);
void s (unsigned short *, unsigned short *);
int
f (int x)
{
unsigned short a[1], c[1];
if (r (a))
return x;
if (c[-1])
s (a, c);
return 0;
}

View File

@ -0,0 +1,20 @@
/* The array offset became 0x1ffffffffffffffe via a conversion from
signed to unsigned HOST_WIDE_INT, causing an ICE compiling for
Thumb. */
int r (unsigned short *);
void s (unsigned short *, unsigned short *);
int
f (int x)
{
unsigned short a[1], c[1];
if (r (a))
return x;
if (c[0x7fffffff])
s (a, c);
return 0;
}