Alias analysis

Michael Hayes m.hayes@elec.canterbury.ac.nz
Sun Jan 17 13:49:00 GMT 1999


I've noticed that alias analysis is being too conservative when
compiling the following function for the C4x.

static int r[100];
static int s[100];

void foo()
{
  int i;
  for (i = 0; i < 100; i++)
      s[i] = r[i];
}

The first problem is that init_alias_analysis is not setting the reg
base value if a memref is loaded from a constant memory location.
For example, reg_base_value[42] is zero for the following insn.

(insn 59 53 65 (set (reg:QI 42)
        (mem/u:QI (symbol_ref/u:QI ("*LC0")) 0)) 5 {movqi_noclobber} (nil)
    (expr_list:REG_EQUAL (symbol_ref:QI ("s"))
        (nil)))

I hacked init_alias_analysis to look for the REG_EQUAL note, without
really knowing what I was doing, so that find_base_value now correctly
returns the base value.

However, I'm still finding that anti_dependence still returns 1 when
considering the addresses r + i and s + i.  Have I missed something
obvious?  If not, does anyone have any clues as to how to solve the
problem?

Here's my hack to alias.c

Index: alias.c
===================================================================
RCS file: /egcs/carton/cvsfiles/egcs/gcc/alias.c,v
retrieving revision 1.46
diff -c -3 -p -r1.46 alias.c
*** alias.c	1998/12/23 07:08:39	1.46
--- alias.c	1999/01/16 03:01:43
*************** init_alias_analysis ()
*** 1417,1429 ****
  	         scan for sets.  A simple set will have no side effects
  	         which could change the base value of any other register. */
  
  	      if (GET_CODE (PATTERN (insn)) == SET
  		  && (find_reg_note (insn, REG_NOALIAS, NULL_RTX)))
  		record_set (SET_DEST (PATTERN (insn)), NULL_RTX);
  	      else
  		note_stores (PATTERN (insn), record_set);
- 
- 	      set = single_set (insn);
  
  	      if (set != 0
  		  && GET_CODE (SET_DEST (set)) == REG
--- 1417,1436 ----
  	         scan for sets.  A simple set will have no side effects
  	         which could change the base value of any other register. */
  
+ 	      set = single_set (insn);
+ 
  	      if (GET_CODE (PATTERN (insn)) == SET
  		  && (find_reg_note (insn, REG_NOALIAS, NULL_RTX)))
  		record_set (SET_DEST (PATTERN (insn)), NULL_RTX);
+ 	      else if (set != 0
+ 		       && GET_CODE (SET_DEST (set)) == REG
+ 		       && REGNO (SET_DEST (set)) >= FIRST_PSEUDO_REGISTER
+ 		       && (((note = find_reg_note (insn, REG_EQUAL, 0)) != 0)))
+ 		note_stores (gen_rtx_SET (GET_MODE (SET_DEST (set)),
+ 					  SET_DEST (set), XEXP (note, 0)), 
+ 			     record_set);
  	      else
  		note_stores (PATTERN (insn), record_set);
  
  	      if (set != 0
  		  && GET_CODE (SET_DEST (set)) == REG

Michael.




More information about the Gcc-bugs mailing list