This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] more robust check for multiplier in addressing mode when determining the costs
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Igor Shevlyakov <igor dot shevlyakov at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 23 Oct 2013 11:57:38 +0200
- Subject: Re: [PATCH] more robust check for multiplier in addressing mode when determining the costs
- Authentication-results: sourceware.org; auth=none
- References: <CAB=oy58iUMdc1a=km=05cLQCMjSZBfNaTe0s9EKLAjrKoU-jiQ at mail dot gmail dot com>
On Wed, Oct 23, 2013 at 1:42 AM, Igor Shevlyakov
<igor.shevlyakov@gmail.com> wrote:
> 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?
I think somebody else fixed this on trunk already.
Richard.
> Thanks
> Igor
>
> 2013-10-22 Igor Shevlyakov <igor.shevlyakov@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);
> }