This is the mail archive of the gcc-patches@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: ivopts cost oddities


Ian Lance Taylor wrote:
> Bernd Schmidt <bernds_cb1@t-online.de> writes:
> 
>> --- tree-ssa-loop-ivopts.c	(revision 118853)
>> +++ tree-ssa-loop-ivopts.c	(working copy)
>> @@ -3321,32 +3321,32 @@ multiply_by_cost (HOST_WIDE_INT cst, enu
>>  /* Returns true if multiplying by RATIO is allowed in address.  */
>>  
>>  bool
>> -multiplier_allowed_in_address_p (HOST_WIDE_INT ratio)
>> +multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, enum machine_mode mode)
> 
> I think this needs a comment about the meaning of MODE.  Is it the
> mode of the memory to which the address points?  Or is it the mode of
> the address computation?
> 
> Same in at least one other place.

I've committed a comment update along with the second patch in the
series, which makes sure we use properly aligned memory addresses when
we try to compute the maximum offsets.  On the Blackfin, SImode memrefs
cannot be (reg + 1), only (reg + 4 * n), so previously we'd terminate
the loop immediately and determine that no offsets were allowed at all.

Bootstrapped and regression tested again on i686-linux, committed as 118863.


Bernd
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 118862)
+++ ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2006-11-15  Bernd Schmidt  <bernd.schmidt@analog.com>
+
+	* tree-ssa-loop-ivopts.c (get_address_cost): Make sure memory
+	addresses we generate for testing are aligned.
+
 2006-11-15  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
 	PR tree-opt/29788
Index: tree-ssa-loop-ivopts.c
===================================================================
--- tree-ssa-loop-ivopts.c	(revision 118856)
+++ tree-ssa-loop-ivopts.c	(working copy)
@@ -3318,7 +3318,8 @@ multiply_by_cost (HOST_WIDE_INT cst, enu
   return cost;
 }
 
-/* Returns true if multiplying by RATIO is allowed in address.  */
+/* Returns true if multiplying by RATIO is allowed in an address.  Test the
+   validity for a memory reference accessing memory of mode MODE.  */
 
 bool
 multiplier_allowed_in_address_p (HOST_WIDE_INT ratio, enum machine_mode mode)
@@ -3361,8 +3362,9 @@ multiplier_allowed_in_address_p (HOST_WI
 
 /* Returns cost of address in shape symbol + var + OFFSET + RATIO * index.
    If SYMBOL_PRESENT is false, symbol is omitted.  If VAR_PRESENT is false,
-   variable is omitted.  The created memory accesses MODE.
-   
+   variable is omitted.  Compute the cost for a memory reference that accesses
+   a memory location of mode MEM_MODE.
+
    TODO -- there must be some better way.  This all is quite crude.  */
 
 static unsigned
@@ -3383,6 +3385,7 @@ get_address_cost (bool symbol_present, b
   if (!initialized[mem_mode])
     {
       HOST_WIDE_INT i;
+      HOST_WIDE_INT start = BIGGEST_ALIGNMENT / BITS_PER_UNIT;
       int old_cse_not_expected;
       unsigned sym_p, var_p, off_p, rat_p, add_c;
       rtx seq, addr, base;
@@ -3393,22 +3396,22 @@ get_address_cost (bool symbol_present, b
       reg1 = gen_raw_REG (Pmode, LAST_VIRTUAL_REGISTER + 1);
 
       addr = gen_rtx_fmt_ee (PLUS, Pmode, reg1, NULL_RTX);
-      for (i = 1; i <= 1 << 20; i <<= 1)
+      for (i = start; i <= 1 << 20; i <<= 1)
 	{
 	  XEXP (addr, 1) = gen_int_mode (i, Pmode);
 	  if (!memory_address_p (mem_mode, addr))
 	    break;
 	}
-      max_offset[mem_mode] = i >> 1;
+      max_offset[mem_mode] = i == start ? 0 : i >> 1;
       off[mem_mode] = max_offset[mem_mode];
 
-      for (i = 1; i <= 1 << 20; i <<= 1)
+      for (i = start; i <= 1 << 20; i <<= 1)
 	{
 	  XEXP (addr, 1) = gen_int_mode (-i, Pmode);
 	  if (!memory_address_p (mem_mode, addr))
 	    break;
 	}
-      min_offset[mem_mode] = -(i >> 1);
+      min_offset[mem_mode] = i == start ? 0 : -(i >> 1);
 
       if (dump_file && (dump_flags & TDF_DETAILS))
 	{

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