This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: memref_conflict_p
- To: law at cygnus dot com
- Subject: Re: memref_conflict_p
- From: Michael Hayes <m dot hayes at elec dot canterbury dot ac dot nz>
- Date: Sun, 29 Nov 1998 22:26:17 +1300 (NZDT)
- Cc: Michael Hayes <m dot hayes at elec dot canterbury dot ac dot nz>, egcs-patches at cygnus dot com
- References: <"13918.10225.870163.495309"@ongaonga.elec.canterbury.ac.nz><16025.912274830@hurl.cygnus.com>
Jeffrey A Law writes:
> Can you fix up those minor issues and resubmit? (I believe it'll be OK when
> you resubmit, but I'd like to peek at it again).
Here's a cleaned up patch, keeping the n_refs argument for generality.
Sun Nov 29 22:17:59 1998 Michael Hayes <m.hayes@elec.canterbury.ac.nz>
* alias.c (addr_side_effect_eval): New function.
(memrefs_conflict_p): Use it.
* rtl.h (addr_side_effect_eval): Prototype it.
Index: rtl.h
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/rtl.h,v
retrieving revision 1.68
diff -c -3 -p -r1.68 rtl.h
*** rtl.h 1998/11/27 10:09:10 1.68
--- rtl.h 1998/11/29 09:14:21
*************** extern void end_alias_analysis PROTO ((
*** 1520,1524 ****
--- 1520,1525 ----
extern void record_base_value PROTO ((int, rtx, int));
extern void record_alias_subset PROTO ((int, int));
+ extern void addr_side_effect_eval PROTO ((rtx, int, int));
#endif /* _RTL_H */
Index: alias.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/alias.c,v
retrieving revision 1.42
diff -c -3 -p -r1.42 alias.c
*** alias.c 1998/10/21 09:53:17 1.42
--- alias.c 1998/11/29 09:14:22
*************** base_alias_check (x, y, x_mode, y_mode)
*** 860,865 ****
--- 860,904 ----
return ! (GET_MODE (x_base) == VOIDmode && GET_MODE (y_base) == VOIDmode);
}
+ /* Modify the memory address ADDR to evaluate and remove the address
+ side effect. The returned address is that of the (N_REFS + 1)th
+ memory reference. */
+
+ rtx
+ addr_side_effect_eval (addr, size, n_refs)
+ rtx addr;
+ int size;
+ int n_refs;
+ {
+ int offset;
+
+ switch (GET_CODE (addr))
+ {
+ case PRE_INC:
+ offset = (n_refs + 1) * size;
+ break;
+ case PRE_DEC:
+ offset = -(n_refs + 1) * size;
+ break;
+ case POST_INC:
+ offset = n_refs * size;
+ break;
+ case POST_DEC:
+ offset = -n_refs * size;
+ break;
+
+ default:
+ return addr;
+ }
+
+ if (offset)
+ addr = gen_rtx_PLUS (GET_MODE (addr), XEXP (addr, 0), GEN_INT (offset));
+ else
+ addr = XEXP (addr, 0);
+
+ return addr;
+ }
+
/* Return nonzero if X and Y (memory addresses) could reference the
same location in memory. C is an offset accumulator. When
C is nonzero, we are testing aliases between X and Y + C.
*************** memrefs_conflict_p (xsize, x, ysize, y,
*** 889,901 ****
else if (GET_CODE (x) == LO_SUM)
x = XEXP (x, 1);
else
! x = canon_rtx (x);
if (GET_CODE (y) == HIGH)
y = XEXP (y, 0);
else if (GET_CODE (y) == LO_SUM)
y = XEXP (y, 1);
else
! y = canon_rtx (y);
if (rtx_equal_for_memref_p (x, y))
{
--- 928,940 ----
else if (GET_CODE (x) == LO_SUM)
x = XEXP (x, 1);
else
! x = canon_rtx (addr_side_effect_eval (x, xsize, 0));
if (GET_CODE (y) == HIGH)
y = XEXP (y, 0);
else if (GET_CODE (y) == LO_SUM)
y = XEXP (y, 1);
else
! y = canon_rtx (addr_side_effect_eval (y, ysize, 0));
if (rtx_equal_for_memref_p (x, y))
{