public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Georg-Johann Lay <avr@gjlay.de>
To: gcc-patches@gcc.gnu.org
Cc: Denis Chertykov <chertykov@gmail.com>,
	 Eric Weddington <eric.weddington@atmel.com>
Subject: [Patch,AVR]: Hack around PR rtl-optimization/52543, Take #2
Date: Tue, 20 Mar 2012 19:54:00 -0000	[thread overview]
Message-ID: <4F68E062.5040202@gjlay.de> (raw)
In-Reply-To: <4F5A4FFE.9000203@gjlay.de>

Dropping the first patch which does not work because at expand-time there
must not be pre-/post-modify addressing :-(

This solutions turns completely away from MEM and addressing modes:
It represents loads from the 16-bits address-spaces as UNSPEC.

The code is as expected now with the additional improvement that loads
to RAMPZ can be factored out if the value is known to be the same
(at least the LDI part; the OUT part is still needed).

Moreover, the code gets simpler because loading the value to OUT to
RAMPZ can be open coded and need not to be hidden in the insn because
reload cannot handle these complicated addresses.

And the patch fixes some more issues:

- avr_load_libgcc_p must only allow __flash because __load_3/4 use LPM.

- Resetting RAMPZ after ELPM for EBI-devices in avr_out_lpm was void in
  some situations because of premature return.
  This is fixed now; the new code is located in avr_load_lpm.

Test suite results look good. There is just a ICE for
  gcc.target/avr/torture/addr-space-2-x.c  -O3 -g
which appears to be PR middle-end/52472

Ok to commit?

Johann

	PR rtl-optimization/52543
	PR target/52461
	* config/avr/avr-protos.h (avr_load_lpm): New prototype.
	* config/avr/avr.c (avr_mode_dependent_address_p): New function.
	(TARGET_MODE_DEPENDENT_ADDRESS_P): New define.
	(avr_load_libgcc_p): Restrict to __flash loads.
	(avr_out_lpm): Only handle 1-byte loads from __flash.
	(avr_load_lpm): New function.
	(avr_find_unused_d_reg): Remove.
	(avr_out_lpm_no_lpmx): Remove.
	(adjust_insn_length): Handle ADJUST_LEN_LOAD_LPM.
	
	* config/avr/avr.md (unspec): Add UNSPEC_LPM.
	(load_<mode>_libgcc): Use UNSPEC_LPM instead of MEM.
	(load_<mode>, load_<mode>_clobber): New insns.
	(mov<mode>): For multi-byte move from non-generic
	16-bit address spaces: Expand to load_<mode> resp.
	load_<mode>_clobber.
	(load<mode>_libgcc): Remove expander.
	(split-lpmx): Remove split.


Georg-Johann Lay wrote:

> The problem with the PR is that lower-subreg.c happily splits multi-byte moves
> from address spaces without knowing anything about the additional costs this is
> causing.
> 
> The TARGET_MODE_DEPENDENT_ADDRESS_P hook cannot be used for 16-bit addresses
> because that hook is not sensitive to address spaces, but is is used for the
> 24-bit address space to avoid subreg lowering for PSImode.
> 
> For the 16-bit address spaces the mov expander now assigns the address register
> by hand as post-increment.
> 
> Luckily, post-increment is the only addressing mode that makes sense with the
> non-generic address spaces and there is no choice for the address register
> resp. addressing mode, anyway...
> 
> This patch does not fix the PR issue, of course, it just avoids subreg lowering
> by using/pretending mode-dependent addresses.
> 
> Ok for trunk?
> 
> Johann
> 
> 	PR rtl-optimization/52543
> 	* config/avr/avr.c (avr_mode_dependent_address_p): New function.
> 	(TARGET_MODE_DEPENDENT_ADDRESS_P): New define.
> 
> 	* config/avr/avr.md (unspec): Add UNSPEC_LPM.
> 	(load_<mode>_libgcc): Use UNSPEC_LPM instead of MEM.
> 	(mov<mode>): For multi-byte move from non-generic
> 	16-bit address spaces: Expand to use Z++ as address for
> 	inline code and use UNSPEC_LPM (Z) for code from libgcc.
> 	(load<mode>_libgcc): Remove expander.
> 	(split-lpmx): Remove split.

  parent reply	other threads:[~2012-03-20 19:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-09 18:47 [Patch,AVR]: Hack around PR rtl-optimization/52543 Georg-Johann Lay
2012-03-19 11:25 ` Ping #1: " Georg-Johann Lay
2012-03-19 11:36   ` Denis Chertykov
2012-03-19 17:29 ` Mike Stump
2012-03-20 19:54 ` Georg-Johann Lay [this message]
2012-03-20 19:56   ` [Patch,AVR]: Hack around PR rtl-optimization/52543, Take #2 Georg-Johann Lay
2012-03-21 11:47     ` Weddington, Eric
2012-03-20 20:06   ` Steven Bosscher
2012-03-21 14:03     ` Georg-Johann Lay

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F68E062.5040202@gjlay.de \
    --to=avr@gjlay.de \
    --cc=chertykov@gmail.com \
    --cc=eric.weddington@atmel.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).