]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-loop-ivopts.c (get_address_cost): Make sure memory addresses we generate...
authorBernd Schmidt <bernd.schmidt@analog.com>
Wed, 15 Nov 2006 17:54:55 +0000 (17:54 +0000)
committerBernd Schmidt <bernds@gcc.gnu.org>
Wed, 15 Nov 2006 17:54:55 +0000 (17:54 +0000)
* tree-ssa-loop-ivopts.c (get_address_cost): Make sure memory
addresses we generate for testing are aligned.

From-SVN: r118863

gcc/ChangeLog
gcc/tree-ssa-loop-ivopts.c

index 382a8a30e093a5c65bbc4307daec9a8e1e540379..a36144b6c60f07e474b177e60fab5b56fee8447f 100644 (file)
@@ -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 b20c309a707d50d19c1344c9d48b1f3d08af7560..29885f2fac7e0165103f64657c4985582787a245 100644 (file)
@@ -3318,7 +3318,8 @@ multiply_by_cost (HOST_WIDE_INT cst, enum machine_mode mode)
   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_WIDE_INT ratio, enum machine_mode mode)
 
 /* 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, bool var_present,
   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, bool var_present,
       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))
        {