public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mkuvyrkov at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/42495] redundant memory load
Date: Tue, 08 Jun 2010 10:41:00 -0000	[thread overview]
Message-ID: <20100608104143.19467.qmail@sourceware.org> (raw)
In-Reply-To: <bug-42495-17659@http.gcc.gnu.org/bugzilla/>



------- Comment #5 from mkuvyrkov at gcc dot gnu dot org  2010-06-08 10:41 -------
Elimination of subsequent calculations of PIC addresses should be handled in
code hoisting optimization.

However, there are two problems that inhibit the optimization:

1. ARM backend outputs calculation of a PIC address as two instructions (load
GOT offset from constant pool and then load PIC address from GOT) and hoist
only handles expressions contained in a single_set().

2. Hoisting algorithm misses many opportunities for expression hoisting to
basic blocks that contain calculation of the expression.  I.e., expr from bb4
will not be hoisted to bb2 even though it is trivially profitable:

bb2:
  expr
  condjump bb4
bb3:
  <no expr>
  jump bb5
bb4:
  expr
bb5:

I'm testing patches to the ARM backend and code hoisting pass which fix the
above problems.  The  generated code calculates address of the global variable
only once:

goo:
        push    {r3, r4, r5, lr}
        ldr     r3, .L6
        ldr     r2, .L6+4
.LPIC0:
        add     r3, pc
        ldr     r5, [r3, r2]
        mov     r4, r0
        ldr     r3, [r5]
        ldr     r0, [r3]
        cmp     r0, #0
        beq     .L2
        mov     r1, r4
        bl      foo
.L2:
        ldr     r3, [r4]
        mov     r0, #0
        cmp     r3, #0
        beq     .L3
        ldr     r2, [r5]
        cmp     r3, r2
        beq     .L3
        ldr     r0, [r3]
.L3:
        @ sp needed for prologue
        pop     {r3, r4, r5, pc}
.L7:
        .align  2
.L6:
        .word   _GLOBAL_OFFSET_TABLE_-(.LPIC0+4)
        .word   gObj(GOT)


-- 

mkuvyrkov at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |mkuvyrkov at gcc dot gnu dot
                   |dot org                     |org
             Status|WAITING                     |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-06-08 10:41:43
               date|                            |


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


  parent reply	other threads:[~2010-06-08 10:41 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-25  7:51 [Bug target/42495] New: " carrot at google dot com
2009-12-25  7:51 ` [Bug target/42495] " carrot at google dot com
2009-12-25  7:52 ` carrot at google dot com
2009-12-31 15:35 ` rguenth at gcc dot gnu dot org
2010-03-19 15:12 ` ramana at gcc dot gnu dot org
2010-03-21  9:18 ` carrot at google dot com
2010-06-08 10:41 ` mkuvyrkov at gcc dot gnu dot org [this message]
2010-07-27 19:35 ` mkuvyrkov at gcc dot gnu dot org
2010-07-27 19:38 ` mkuvyrkov at gcc dot gnu dot org
2010-07-27 19:42 ` mkuvyrkov at gcc dot gnu dot org
2010-07-27 19:45 ` mkuvyrkov at gcc dot gnu dot org
2010-07-27 19:48 ` mkuvyrkov at gcc dot gnu dot org
2010-07-27 21:07 ` mkuvyrkov at gcc dot gnu dot org
2010-07-27 21:11 ` mkuvyrkov at gcc dot gnu dot 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=20100608104143.19467.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).