This is the mail archive of the gcc@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]

Re: memref_conflict_p


Jeffrey A Law writes:
 > Sounds like a mistake to me.  I've had to beat on the alias code in the past
 > to improve autoinc support, so it wouldn't suprise me if there are
 > areas where it is still weak.


Can someone more knowledgeable with this alias code check out the
following patch I've thrown together from a function
(addr_side_effect_eval) I had lying around.

Michael.


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/27 04:14:10 *************** base_alias_check (x,
y, x_mode, y_mode) *** 860,865 **** --- 860,899 ----
    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.  */
+ static rtx
+ addr_side_effect_eval (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))
      {
--- 923,935 ----
    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))
      {



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