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]
Other format: [Raw text]

Re: Alias analysis - does base_alias_check still work ?


On Fri, Jul 19, 2002 at 09:55:00PM +0200, Toon Moene wrote:
> Well, it obviously doesn't work on the Alpha.  First of all I have to
> specify -fno-rerun-loop-opts to get any loop unrolling at all, and then the
> unrolled loop looks like this:

Havn't looked at what exactly goes wrong with rerun-loop-opts,
except to notice that loop loses track of the register that
contains the iteration count.

As for the aliasing, the problem is that Alpha doesn't have
indexed addressing, so we wind up with the base addresses being
strength reduced, and presumably that confuses the alias
analysis code enough that it considers the memory references
to be "variable", and thus may alias anything.

One solution is to make use of the new MEM_EXPR field and
record this information such that it can't (or shouldn't)
get lost ever.

Try the following.  For me it cleans up the example a bit:

$L6:
	lds $f10,0($18)
	lds $f12,-4($3)
	lda $1,-3($5)
	lda $5,-4($5)
	lds $f11,4($18)
	lds $f13,8($18)
	addl $1,$31,$4
	lds $f14,12($18)
	lda $18,16($18)
	muls $f15,$f10,$f10
	muls $f15,$f11,$f11
	muls $f15,$f13,$f13
	muls $f15,$f14,$f14
	adds $f12,$f10,$f12
	sts $f12,-4($2)
	lds $f10,0($3)
	adds $f10,$f11,$f10
	sts $f10,0($2)
	lds $f11,4($3)
	adds $f11,$f13,$f11
	sts $f11,4($2)
	lds $f10,8($3)
	lda $3,16($3)
	adds $f10,$f14,$f10
	sts $f10,8($2)
	lda $2,16($2)
	bge $4,$L6

The remaining sts/lds pairs are writes then reads from SY.
We've lost track of the fact that the write is to index I
and the read from index I+1, and so cannot overlap.


r~



Index: alias.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/alias.c,v
retrieving revision 1.177
diff -c -p -d -r1.177 alias.c
*** alias.c	20 Jun 2002 07:29:59 -0000	1.177
--- alias.c	19 Jul 2002 22:23:34 -0000
*************** nonoverlapping_memrefs_p (x, y)
*** 1957,1962 ****
--- 1957,1970 ----
        moffsetx = adjust_offset_for_component_ref (exprx, moffsetx);
        exprx = t;
      }
+   else if (TREE_CODE (exprx) == INDIRECT_REF)
+     {
+       exprx = TREE_OPERAND (exprx, 0);
+       if (flag_argument_noalias < 2
+ 	  || TREE_CODE (exprx) != PARM_DECL)
+ 	return 0;
+     }
+ 
    moffsety = MEM_OFFSET (y);
    if (TREE_CODE (expry) == COMPONENT_REF)
      {
*************** nonoverlapping_memrefs_p (x, y)
*** 1965,1970 ****
--- 1973,1985 ----
  	return 0;
        moffsety = adjust_offset_for_component_ref (expry, moffsety);
        expry = t;
+     }
+   else if (TREE_CODE (expry) == INDIRECT_REF)
+     {
+       expry = TREE_OPERAND (expry, 0);
+       if (flag_argument_noalias < 2
+ 	  || TREE_CODE (expry) != PARM_DECL)
+ 	return 0;
      }
  
    if (! DECL_P (exprx) || ! DECL_P (expry))
Index: emit-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/emit-rtl.c,v
retrieving revision 1.284
diff -c -p -d -r1.284 emit-rtl.c
*** emit-rtl.c	11 Jul 2002 10:32:54 -0000	1.284
--- emit-rtl.c	19 Jul 2002 22:23:34 -0000
*************** set_mem_attributes (ref, t, objectp)
*** 1805,1811 ****
  	    }
  	  while (TREE_CODE (t) == ARRAY_REF);
  
! 	  if (TREE_CODE (t) == COMPONENT_REF)
  	    {
  	      expr = component_ref_for_mem_expr (t);
  	      if (host_integerp (off_tree, 1))
--- 1805,1821 ----
  	    }
  	  while (TREE_CODE (t) == ARRAY_REF);
  
! 	  if (DECL_P (t))
! 	    {
! 	      expr = t;
! 	      if (host_integerp (off_tree, 1))
! 		offset = GEN_INT (tree_low_cst (off_tree, 1));
! 	      size = (DECL_SIZE_UNIT (t)
! 		      && host_integerp (DECL_SIZE_UNIT (t), 1)
! 		      ? GEN_INT (tree_low_cst (DECL_SIZE_UNIT (t), 1)) : 0);
! 	      align = DECL_ALIGN (t);
! 	    }
! 	  else if (TREE_CODE (t) == COMPONENT_REF)
  	    {
  	      expr = component_ref_for_mem_expr (t);
  	      if (host_integerp (off_tree, 1))
*************** set_mem_attributes (ref, t, objectp)
*** 1813,1818 ****
--- 1823,1845 ----
  	      /* ??? Any reason the field size would be different than
  		 the size we got from the type?  */
  	    }
+ 	  else if (flag_argument_noalias > 1
+ 		   && TREE_CODE (t) == INDIRECT_REF
+ 		   && TREE_CODE (TREE_OPERAND (t, 0)) == PARM_DECL)
+ 	    {
+ 	      expr = t;
+ 	      offset = NULL;
+ 	    }
+ 	}
+ 
+       /* If this is a Fortran indirect argument reference, record the
+ 	 parameter decl.  */
+       else if (flag_argument_noalias > 1
+ 	       && TREE_CODE (t) == INDIRECT_REF
+ 	       && TREE_CODE (TREE_OPERAND (t, 0)) == PARM_DECL)
+ 	{
+ 	  expr = t;
+ 	  offset = NULL;
  	}
      }
  
Index: print-rtl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/print-rtl.c,v
retrieving revision 1.84
diff -c -p -d -r1.84 print-rtl.c
*** print-rtl.c	18 Jun 2002 20:12:13 -0000	1.84
--- print-rtl.c	19 Jul 2002 22:23:34 -0000
*************** print_mem_expr (outfile, expr)
*** 92,97 ****
--- 92,103 ----
  	fprintf (outfile, ".%s",
  		 IDENTIFIER_POINTER (DECL_NAME (TREE_OPERAND (expr, 1))));
      }
+   else if (TREE_CODE (expr) == INDIRECT_REF)
+     {
+       fputs (" (*", outfile);
+       print_mem_expr (outfile, TREE_OPERAND (expr, 0));
+       fputs (")", outfile);
+     }
    else if (DECL_NAME (expr))
      fprintf (outfile, " %s", IDENTIFIER_POINTER (DECL_NAME (expr)));
    else if (TREE_CODE (expr) == RESULT_DECL)


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