Bug 56590 - Replace auto-inc-dec pass with generic address mode selection pass
Summary: Replace auto-inc-dec pass with generic address mode selection pass
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: rtl-optimization (show other bugs)
Version: 4.8.0
: P3 enhancement
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: missed-optimization
Depends on:
Blocks: 50749 52049 53911 54065 19078 39423
  Show dependency treegraph
 
Reported: 2013-03-10 17:05 UTC by Oleg Endo
Modified: 2023-07-22 03:07 UTC (History)
0 users

See Also:
Host:
Target: sh*-*-*
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oleg Endo 2013-03-10 17:05:28 UTC
At least on SH there are several address mode selection issues which I'd like to group in this PR.

PR 54065
[SH] Prefer @(R0,Rn) addressing for floating-point load/store

PR 53911
[SH] Improve displacement addressing

PR 50749
Auto-inc-dec does not find subsequent contiguous mem accesses

PR 39423
[4.6/4.7/4.8 Regression] [SH] performance regression: lost mov @(disp,Rn)

PR 52049
SH Target: Inefficient constant address access

Based on my observations so far, I think the right thing to do is to replace the current auto-inc-dec pass with a pass that optimizes address mode selection in a more generic way, instead of just trying to find auto inc/dec opportunities.

The basic idea is to look at all memory accesses in a function (or basic block as a start) that share a base address and then try to select the cheapest addressing modes for each memory access.  The current address cost target hook can be used to determine the costs of a memory access with a particular address.

I have already started working on such a replacement pass a while ago and would like to first do a trial with the SH target.  Other targets might then also pick it up if it seems beneficial to do so.
Comment 1 bin cheng 2015-02-03 02:23:51 UTC
This surely sounds interesting.  Like I suggested in PR62173, RTL optimizer might be able to do more in address expression re-association and addressing mode choosing.
But it's difficult to change base/offset for addresses which are IVOPTed on GIMPLE.
Comment 2 Oleg Endo 2015-02-03 10:59:02 UTC
(In reply to amker from comment #1)
> This surely sounds interesting.  Like I suggested in PR62173, RTL optimizer
> might be able to do more in address expression re-association and addressing
> mode choosing.
> But it's difficult to change base/offset for addresses which are IVOPTed on
> GIMPLE.

(Proper) AMS is a difficult problem and depends a lot on the target address mode capabilities and the context of the memory accesses.  I wouldn't try to do that on GIMPLE or in ivopt.  There's simply not enough information on the instructions that will be used for actually carrying out the memory accesses.  Whatever is done on GIMPLE without taking the target into account will result in missed optimization cases eventually.  I would rather not distribute the AMS problem across sevaral compilation phases like doing a bit on GIMPLE and doing a bit on RTL later.  Of course it'd be helpful if the tree optimizers can prepare some things that make AMS optimization more successful.  But generally I think an AMS pass should be able to work on its own.
Comment 3 Oleg Endo 2015-05-22 13:57:50 UTC
There is a GSoC 2015 project which will try to address the AMS problem.
https://www.google-melange.com/gsoc/project/details/google/gsoc2015/erikvarga/5693417237512192

It will be initially for SH.  If it works out, it can be generalized so that other targets can benefit from it, too.
Comment 4 Oleg Endo 2015-10-03 15:31:52 UTC
The AMS branch is here: https://github.com/erikvarga/gcc