public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hutchinsonandy at aim dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/34789] [avr] sometimes the compiler keeps addresses in registers unnecessarily
Date: Fri, 22 Feb 2008 01:22:00 -0000	[thread overview]
Message-ID: <20080222012212.18897.qmail@sourceware.org> (raw)
In-Reply-To: <bug-34789-15632@http.gcc.gnu.org/bugzilla/>



------- Comment #1 from hutchinsonandy at aim dot com  2008-02-22 01:22 -------
This appears to be due to avr_rtx_costs not assigning same cost to SYMBOL_REF
and CONST_INT. So SYMBOL_REF looks expensive - so is held in register to avoid
"recalculating" it.

Quick change to make SYMBOL_REF same cost as CONST_INT in both avr_rtx_cost and
avr_operand_rtx_cost gave the desired result 

  22                    /* prologue: function */
  23                    /* frame size = 0 */
  24                    .LM2:
  25 0000 E091 0000             lds r30,a
  26 0004 F091 0000             lds r31,(a)+1
  27 0008 EE0F                  lsl r30
  28 000a FF1F                  rol r31
  29 000c E050                  subi r30,lo8(-(data))
  30 000e F040                  sbci r31,hi8(-(data))
  31 0010 8081                  ld r24,Z
  32 0012 9181                  ldd r25,Z+1
  33 0014 0E94 0000             call foo
  34                    .LM3:
  35 0018 FC01                  movw r30,r24
  36 001a EE0F                  lsl r30
  37 001c FF1F                  rol r31
  38 001e E050                  subi r30,lo8(-(data))
  39 0020 F040                  sbci r31,hi8(-(data))
  40 0022 8081                  ld r24,Z
  41 0024 9181                  ldd r25,Z+1
  42 0026 0E94 0000             call foo
  43                    /* epilogue start */
  44                    .LM4:
  45 002a 0895                  ret

CONST and LABEL_REF might also have same problem as they cost same as MEM.

But note, if SYMBOL_REF were part of memory address, then it might be better
held in register (like Y or Z) - this should be done by checking outer code.
With outer code of "MEM" SYMBOL_REF would be more expensive than register.
(which might same a few LDS/STS that appear in code)

Avr_rtx_cost needs some serious work done to correct these are other anomalies
in cost assumptions and the recursion on operand costs.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34789


  reply	other threads:[~2008-02-22  1:22 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-15  9:04 [Bug c/34789] New: Missed optimisation on avr - " david at westcontrol dot com
2008-02-22  1:22 ` hutchinsonandy at aim dot com [this message]
2008-04-04 21:32 ` [Bug target/34789] [avr] " eric dot weddington at atmel dot com
     [not found] <bug-34789-4@http.gcc.gnu.org/bugzilla/>
2011-10-09 20:49 ` gjl at gcc dot gnu.org

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=20080222012212.18897.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).