public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Georg-Johann Lay <avr@gjlay.de>
To: Denis Chertykov <chertykov@gmail.com>
Cc: gcc-patches@gcc.gnu.org, Anatoly Sokolov <aesok@post.ru>,
	 "Eric B. Weddington" <eric.weddington@atmel.com>
Subject: Re: [Patch, AVR]: Fix PR46779
Date: Fri, 10 Jun 2011 10:23:00 -0000	[thread overview]
Message-ID: <4DF1ED76.4030507@gjlay.de> (raw)
In-Reply-To: <BANLkTi=VAo8UcLDsvBp5vWk3qaO5RQvAKg@mail.gmail.com>

Denis Chertykov schrieb:
> 2011/6/9 Georg-Johann Lay <avr@gjlay.de>:
>> Denis Chertykov schrieb:
>>> 2011/6/9 Georg-Johann Lay <avr@gjlay.de>:
>> I agree with you. However, I think that the risk of spill failure
>> should be minimized. I have no idea how to fix a splill failure like
>> the following that occurs in testsuite (with -Os, no matter if the
>> patch is applied or not):
>>
>> ./gcc/testsuite/gcc.c-torture/execute/pr38051.c:189:1: error: unable
>> to find a register to spill in class 'POINTER_REGS'
>> ./gcc/testsuite/gcc.c-torture/execute/pr38051.c:189:1: error: this is
>> the insn:
>> (insn 61 60 62 10 (set (reg/v:SI 12 r12 [orig:73 b0 ] [73])
>>        (mem:SI (subreg:HI (reg/v:SI 70 [ srcp2 ]) 0) [2 *D.2218_56+0
>> S4 A8])) ./gcc/testsuite/gcc.c-torture/execute/pr38051.c:64 12 {*movsi}
>>     (nil))
>> ./gcc/testsuite/gcc.c-torture/execute/pr38051.c:189:1: internal
>> compiler error: in spill_failure, at reload1.c:2113
>>
>> Actually I have no idea if the snip in avr_hard_regno_mode_ok actually
>> would reduce the risk of spill failure :-/
> 
> I think, no.
> I will try to debug reload for pr38051.c (It will be a long process 1-2 weeks)
> 
> Denis.

Thanks for doing that! Debugging reload is really no fun...

I see spill fails for these test cases with -mmcu=atmega128

* gcc.c-torture/execute/pr38051.c (-Os)
* gcc.dg/pr43670.c      (-O -ftree-vrp -fcompare-debug)
* gcc.dg/20030324-1.c   (-O -fstrict-aliasing -fgcse)

all complainins contain RTX like

   (mem:SI/SF (subreg:HI (reg:SI xxx) 0/2))


Then I have a question on spill failures:

There is PR46278, an optimization flaw that goes as follows:

The avr BE defines fake addressing mode X+const that has to be written
down in asm as
  X += const
  a = *X
  X -= const

The comment says that this is just to cover a corner case, however the
new register allocator uses this case more often or even greedily.
There is no way to describe the cost for such an access, and as X has
lower prologue/epilogue cost than Y, X is preferred over Y often.

In 4.7, I see that flaw less often than in 4.5.  However, I think the
best way is not to lie at the register allocator and not to supply a
fake instruction like that.

So I started to work on a fix. The changes in avr.h are:

	* config/avr/avr.h (BASE_REG_CLASS): Remove.
	(REG_OK_FOR_BASE_NOSTRICT_P): Remove.
	(REG_OK_FOR_BASE_STRICT_P): Remove.
	(MODE_CODE_BASE_REG_CLASS): New Define.
	(REGNO_MODE_CODE_OK_FOR_BASE_P): New Define.

The macros REGNO_MODE_CODE_OK_FOR_BASE_P and MODE_CODE_BASE_REG_CLASS
allow a better, fine grained control over addressing modes for each
hard register and allow to support X without fake instructions. The
code quality actually improves, but I see a new spill failure for the
test case

* gcc.c-torture/compile/950612-1.c

On the one hand, that test case has heavy long long use and is no
"real world code" to run on AVR. On the other hand, I don't think
trading code quality here against ICE there is a good idea.

What do you think about that? As I have no idea how to fix a spill
failure in the backend, I stopped working on a patch.

Then I observed trouble with DI patterns during libgcc build and had
to remove

* "zero_extendqidi2"
* "zero_extendhidi2"
* "zero_extendsidi2"

These are "orphan" insns: they deal with DI without having movdi
support so I removed them.

Johann

  reply	other threads:[~2011-06-10 10:14 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-09 17:24 Georg-Johann Lay
2011-06-09 18:50 ` Denis Chertykov
2011-06-09 19:43   ` Georg-Johann Lay
2011-06-09 19:51     ` Denis Chertykov
2011-06-10 10:23       ` Georg-Johann Lay [this message]
2011-06-12 10:34         ` Denis Chertykov
2011-06-13 18:10           ` Georg-Johann Lay
2011-06-13 22:37             ` Denis Chertykov
2011-06-14 10:39               ` Georg-Johann Lay
2011-06-14 11:38                 ` Denis Chertykov
2011-06-14 21:38                   ` Georg-Johann Lay
2011-06-14 23:04                     ` Richard Henderson
2011-06-15 17:58                     ` Richard Henderson
2011-06-15 21:58                       ` Georg-Johann Lay
2011-06-15 22:20                         ` Richard Henderson
2011-06-16  3:46                           ` Richard Henderson
2011-06-16 11:37                             ` Denis Chertykov
2011-06-16 12:01                               ` Denis Chertykov
2011-06-16 14:07                                 ` Richard Henderson
2011-06-16 18:18                                   ` Denis Chertykov
2011-06-16 18:57                                     ` Richard Henderson
2011-06-16 19:33                                       ` Denis Chertykov
2011-06-16 19:42                                         ` Richard Henderson
2011-06-16 20:04                                           ` Denis Chertykov
2011-06-16 14:36                               ` Richard Henderson
2011-06-16 14:52                                 ` Bernd Schmidt
2011-06-16 15:13                                   ` Richard Henderson
2011-06-16 18:57                                 ` Denis Chertykov
2011-06-23 20:48                             ` Denis Chertykov
2011-06-23 22:04                               ` Richard Henderson
2011-06-26 20:03                                 ` Denis Chertykov
2011-06-26 20:51                                   ` Georg-Johann Lay
2011-06-27  8:41                                     ` Denis Chertykov
2011-06-27  9:19                                       ` Georg-Johann Lay
2011-06-27 10:17                                         ` Denis Chertykov
2011-07-07  9:59                                           ` Georg-Johann Lay
2011-07-07 18:21                                             ` Denis Chertykov
2011-07-08 10:12                                               ` Georg-Johann Lay
2011-07-08 10:25                                                 ` Denis Chertykov
2011-07-08 12:16                                                   ` Georg-Johann Lay
2011-06-22  3:28             ` Hans-Peter Nilsson
2011-06-22 17:03               ` Georg-Johann Lay
2011-06-23 12:51                 ` Hans-Peter Nilsson
2011-06-23 13:00                 ` Hans-Peter Nilsson
2011-06-09 20:03     ` Georg-Johann Lay
2011-06-10  9:27   ` Georg-Johann Lay
2011-06-21 17:17     ` 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=4DF1ED76.4030507@gjlay.de \
    --to=avr@gjlay.de \
    --cc=aesok@post.ru \
    --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).