I'm working on a chip with some unusual addressing modes.
it does have [base_rage+msize*index_reg] and one can't omit base_reg like
on x86.
But when ivopts tries to calculate the costs of different addressing modes
it only checks [mult*reg] to determine allowable multipliers.
I modified multiplier_allowed_in_address_p to check both cases.

There's no actual testcase that fails it's just my back-end generated
sub-optimal code.
I tested it on my tree off 4.8.1 and it fixes the problem.
Rebuilt trunk for x86_64-linux-gnu.

Should it be included in trunk to make check more robust?

Thanks
Igor

2013-10-22  Igor Shevlyakov  <igor.shevlya...@gmail.com>

* tree-ssa-loop-ivopts.c (multiplier_allowed_in_address_p ): Check both
  [reg+mult*reg] and [mult*reg] to determine if multiplier is allowed.


Index: tree-ssa-loop-ivopts.c
===================================================================
--- tree-ssa-loop-ivopts.c (revision 203937)
+++ tree-ssa-loop-ivopts.c (working copy)
@@ -3108,16 +3108,19 @@ multiplier_allowed_in_address_p (HOST_WI
     {
       enum machine_mode address_mode = targetm.addr_space.address_mode
(as);
       rtx reg1 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 1);
-      rtx addr;
+      rtx reg2 = gen_raw_REG (address_mode, LAST_VIRTUAL_REGISTER + 2);
+      rtx addr, scaled;
       HOST_WIDE_INT i;

       valid_mult = sbitmap_alloc (2 * MAX_RATIO + 1);
       bitmap_clear (valid_mult);
-      addr = gen_rtx_fmt_ee (MULT, address_mode, reg1, NULL_RTX);
+      scaled = gen_rtx_fmt_ee (MULT, address_mode, reg1,   NULL_RTX);
+      addr   = gen_rtx_fmt_ee (PLUS, address_mode, scaled, reg2);
       for (i = -MAX_RATIO; i <= MAX_RATIO; i++)
  {
-  XEXP (addr, 1) = gen_int_mode (i, address_mode);
-  if (memory_address_addr_space_p (mode, addr, as))
+  XEXP (scaled, 1) = gen_int_mode (i, address_mode);
+  if (memory_address_addr_space_p (mode, addr, as) ||
+      memory_address_addr_space_p (mode, scaled, as))
     bitmap_set_bit (valid_mult, i + MAX_RATIO);
  }

Reply via email to