This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
nonoverlapping_memrefs_p: fix off by one error
- From: Dan Nicolaescu <dann at godzilla dot ICS dot UCI dot EDU>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 31 May 2002 06:17:20 -0700
- Subject: nonoverlapping_memrefs_p: fix off by one error
When compiling
struct complex { double re, im; };
complex add(complex z1, complex z2)
{
complex w;
w.re = z1.re + z2.re;
w.im = z1.im + z2.im;
return w;
}
with -O3 -mcpu=v9 -m64 on a sparc
nonoverlapping_memrefs_p returns 0 when called with
x = (mem/s:DF (plus:DI (reg/f:DI 101 %sfp)
(const_int 136 [0x88])) [2 z1+8 S8 A64])
y = (mem/s:DF (plus:DI (reg/f:DI 101 %sfp)
(const_int 128 [0x80])) [2 z1+0 S8 A64])
This is caused by an off by one comparison error.
I have to go to bed, I haven't tested the patch too much, but it looks
correct.
2002-05-31 Dan Nicolaescu <dann@ics.uci.edu>
* alias.c (nonoverlapping_memrefs_p): Fix off by one error.
Index: alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.170
diff -c -3 -p -c -r1.170 alias.c
*** alias.c 22 Apr 2002 18:17:06 -0000 1.170
--- alias.c 31 May 2002 13:08:06 -0000
*************** nonoverlapping_memrefs_p (x, y)
*** 2021,2027 ****
/* If we don't know the size of the lower-offset value, we can't tell
if they conflict. Otherwise, we do the test. */
! return sizex >= 0 && offsety > offsetx + sizex;
}
/* True dependence: X is read after store in MEM takes place. */
--- 2175,2181 ----
/* If we don't know the size of the lower-offset value, we can't tell
if they conflict. Otherwise, we do the test. */
! return sizex >= 0 && offsety >= offsetx + sizex;
}
/* True dependence: X is read after store in MEM takes place. */