public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/43129] Simplify global variable's address loading with option -fpic
       [not found] <bug-43129-4@http.gcc.gnu.org/bugzilla/>
@ 2010-10-14 16:33 ` stephen.clarke at st dot com
       [not found] ` <201010141633.o9EGXcYL022132@rly04e.srv.mailcontrol.com>
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 14+ messages in thread
From: stephen.clarke at st dot com @ 2010-10-14 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

Stephen Clarke <stephen.clarke at st dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |stephen.clarke at st dot
                   |                            |com

--- Comment #8 from Stephen Clarke <stephen.clarke at st dot com> 2010-10-14 16:32:56 UTC ---
For arm instruction set, could you fold pc into the indexing
to save an instruction?

foo:
        ldr     r3, .L2        // C
.LPIC0:
        ldr     r3, [r3,pc]    // C
        @ sp needed for prologue
        ldr     r2, [r3]
        str     r0, [r3]
        mov     r0, r2
        bx      lr
.L3:
        .align  2
.L2:
        .word   ABS_ADDRESS_OF_GOT_ENTRY_FOR_i -(.LPIC0+4) // C


^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [Bug target/43129] Simplify global variable's address loading with option -fpic
       [not found] ` <201010141633.o9EGXcYL022132@rly04e.srv.mailcontrol.com>
@ 2010-10-14 16:39   ` Ramana Radhakrishnan
  0 siblings, 0 replies; 14+ messages in thread
From: Ramana Radhakrishnan @ 2010-10-14 16:39 UTC (permalink / raw)
  To: stephen.clarke at st dot com; +Cc: gcc-bugs


On Thu, 2010-10-14 at 16:33 +0000, stephen.clarke at st dot com wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43129
> 
> Stephen Clarke <stephen.clarke at st dot com> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |stephen.clarke at st dot
>                    |                            |com
> 
> --- Comment #8 from Stephen Clarke <stephen.clarke at st dot com> 2010-10-14 16:32:56 UTC ---
> For arm instruction set, could you fold pc into the indexing
> to save an instruction?
> 
> foo:
>         ldr     r3, .L2        // C
> .LPIC0:
>         ldr     r3, [r3,pc]    // C


You'll find that the ARM-ARM thinks that PC in any of the 3 locations in this instruction form is *unpredictable*. Thus this form of the instruction should not be used. 

cheers
Ramana


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
       [not found] <bug-43129-4@http.gcc.gnu.org/bugzilla/>
  2010-10-14 16:33 ` [Bug target/43129] Simplify global variable's address loading with option -fpic stephen.clarke at st dot com
       [not found] ` <201010141633.o9EGXcYL022132@rly04e.srv.mailcontrol.com>
@ 2010-10-14 16:40 ` ramana.radhakrishnan at arm dot com
  2010-10-14 17:02 ` stephen.clarke at st dot com
  2014-02-16 13:15 ` jackie.rosen at hushmail dot com
  4 siblings, 0 replies; 14+ messages in thread
From: ramana.radhakrishnan at arm dot com @ 2010-10-14 16:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from ramana.radhakrishnan at arm dot com <ramana.radhakrishnan at arm dot com> 2010-10-14 16:39:26 UTC ---
On Thu, 2010-10-14 at 16:33 +0000, stephen.clarke at st dot com wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43129
> 
> Stephen Clarke <stephen.clarke at st dot com> changed:
> 
>            What    |Removed                     |Added
> ----------------------------------------------------------------------------
>                  CC|                            |stephen.clarke at st dot
>                    |                            |com
> 
> --- Comment #8 from Stephen Clarke <stephen.clarke at st dot com> 2010-10-14 16:32:56 UTC ---
> For arm instruction set, could you fold pc into the indexing
> to save an instruction?
> 
> foo:
>         ldr     r3, .L2        // C
> .LPIC0:
>         ldr     r3, [r3,pc]    // C


You'll find that the ARM-ARM thinks that PC in any of the 3 locations in this
instruction form is *unpredictable*. Thus this form of the instruction should
not be used. 

cheers
Ramana


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
       [not found] <bug-43129-4@http.gcc.gnu.org/bugzilla/>
                   ` (2 preceding siblings ...)
  2010-10-14 16:40 ` ramana.radhakrishnan at arm dot com
@ 2010-10-14 17:02 ` stephen.clarke at st dot com
  2014-02-16 13:15 ` jackie.rosen at hushmail dot com
  4 siblings, 0 replies; 14+ messages in thread
From: stephen.clarke at st dot com @ 2010-10-14 17:02 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Stephen Clarke <stephen.clarke at st dot com> 2010-10-14 17:01:47 UTC ---
OK, I can see that the ARM ARM states for Rm == PC then its unpredictable.

But for Rn == PC, I can only see that its unpredictable if W is 1
or P is 0  (I am looking at encoding A1).  So I am struggling to
understand that:

   ldr     r3, [pc,r3]

is unpredictable.  Forgive me if I made a mistake, my knowledge of
ARM is a little rusty.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
       [not found] <bug-43129-4@http.gcc.gnu.org/bugzilla/>
                   ` (3 preceding siblings ...)
  2010-10-14 17:02 ` stephen.clarke at st dot com
@ 2014-02-16 13:15 ` jackie.rosen at hushmail dot com
  4 siblings, 0 replies; 14+ messages in thread
From: jackie.rosen at hushmail dot com @ 2014-02-16 13:15 UTC (permalink / raw)
  To: gcc-bugs

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

Jackie Rosen <jackie.rosen at hushmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jackie.rosen at hushmail dot com

--- Comment #11 from Jackie Rosen <jackie.rosen at hushmail dot com> ---
*** Bug 260998 has been marked as a duplicate of this bug. ***
Seen from the domain http://volichat.com
Page where seen: http://volichat.com/adult-chat-rooms
Marked for reference. Resolved as fixed @bugzilla.


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
  2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
                   ` (7 preceding siblings ...)
  2010-04-11 12:09 ` carrot at google dot com
@ 2010-04-11 12:13 ` carrot at google dot com
  8 siblings, 0 replies; 14+ messages in thread
From: carrot at google dot com @ 2010-04-11 12:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from carrot at google dot com  2010-04-11 12:12 -------
(In reply to comment #6)
> Some experiment results:
> 
> Compile CSiBE with options -Os -fpic -mthumb -fno-short-enums
> 
> without this optimization: 2830665
> simplify-got before ra:    2825737
> simplify-got after ra:     2826853

These numbers are sum of each line in file result-size.csv.


-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
  2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
                   ` (6 preceding siblings ...)
  2010-04-08 13:32 ` carrot at google dot com
@ 2010-04-11 12:09 ` carrot at google dot com
  2010-04-11 12:13 ` carrot at google dot com
  8 siblings, 0 replies; 14+ messages in thread
From: carrot at google dot com @ 2010-04-11 12:09 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from carrot at google dot com  2010-04-11 12:09 -------
Some experiment results:

Compile CSiBE with options -Os -fpic -mthumb -fno-short-enums

without this optimization: 2830665
simplify-got before ra:    2825737
simplify-got after ra:     2826853

So this optimization should be done before RA. 


-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
  2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
                   ` (5 preceding siblings ...)
  2010-04-07 15:45 ` rth at gcc dot gnu dot org
@ 2010-04-08 13:32 ` carrot at google dot com
  2010-04-11 12:09 ` carrot at google dot com
  2010-04-11 12:13 ` carrot at google dot com
  8 siblings, 0 replies; 14+ messages in thread
From: carrot at google dot com @ 2010-04-08 13:32 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from carrot at google dot com  2010-04-08 13:31 -------
(In reply to comment #4)
> I guess you'll have to experiment with your implementation to
> see what gives the best results on a large body of code.
> 

I will experiment on CSiBE.


-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
  2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
                   ` (4 preceding siblings ...)
  2010-03-31  8:01 ` carrot at google dot com
@ 2010-04-07 15:45 ` rth at gcc dot gnu dot org
  2010-04-08 13:32 ` carrot at google dot com
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: rth at gcc dot gnu dot org @ 2010-04-07 15:45 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from rth at gcc dot gnu dot org  2010-04-07 15:45 -------
My best guess is that this optimization should be done late.
For instance, in the machine-dependant reorg pass.  I don't
see any place to hook this earlier.

The problem is that reload should be able to "spill" pseudos
containing your got addresses and re-compute them from the
given constants rather than consuming a stack slot to hold
the computed value.  Which means that the number of instances
of got address loads may vary until after reload, which means
that any size estimation calculation you do earlier can be off.

The down-side to doing it after reload is that you will have
committed to saving and restoring arm_pic_register in the prologue
and epilogue.  Given that arm uses ldm/stm this ought not impact
your code size often, but will in the extreme case of a leaf
function with no other saved registers.

I guess you'll have to experiment with your implementation to
see what gives the best results on a large body of code.


-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
  2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
                   ` (3 preceding siblings ...)
  2010-03-30 14:36 ` ebotcazou at gcc dot gnu dot org
@ 2010-03-31  8:01 ` carrot at google dot com
  2010-04-07 15:45 ` rth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: carrot at google dot com @ 2010-03-31  8:01 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from carrot at google dot com  2010-03-31 08:01 -------
(In reply to comment #2)
> Doesn't this belong in the linker as a relaxation?  This would solve the reloc
> problem in the process.
> 

Gnu linker has already support R_ARM_GOT_PREL. And the new relocation
(GOT_PREL) has been added to trunk gas. So the offset can be represented as

      i(GOT_PREL)+(.-(.LPIC1+4))

Now my question is where is the best place to insert this enhancement?


-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
  2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
                   ` (2 preceding siblings ...)
  2010-03-16  6:24 ` carrot at google dot com
@ 2010-03-30 14:36 ` ebotcazou at gcc dot gnu dot org
  2010-03-31  8:01 ` carrot at google dot com
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: ebotcazou at gcc dot gnu dot org @ 2010-03-30 14:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from ebotcazou at gcc dot gnu dot org  2010-03-30 14:36 -------
Doesn't this belong in the linker as a relaxation?  This would solve the reloc
problem in the process.


-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
  2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
  2010-02-20 12:41 ` [Bug target/43129] " steven at gcc dot gnu dot org
  2010-02-22 14:10 ` rearnsha at gcc dot gnu dot org
@ 2010-03-16  6:24 ` carrot at google dot com
  2010-03-30 14:36 ` ebotcazou at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: carrot at google dot com @ 2010-03-16  6:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from carrot at google dot com  2010-03-16 06:23 -------
This optimization uses one less register (the register hold the GOT base), to
get this beneficial the ideal place for it should be before register
allocation.

Usually expand pass generates instructions to load global variable's address
from GOT entry for each access of the global variable. Later cse/gcse passes
can remove many of them. In order to precisely model the cost, this
optimization should be put after some cse/gcse passes.

So what is the best place for this optimization? Is there any existed pass can
be enhanced with this optimization? Or should I add a new pass?


-- 


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
  2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
  2010-02-20 12:41 ` [Bug target/43129] " steven at gcc dot gnu dot org
@ 2010-02-22 14:10 ` rearnsha at gcc dot gnu dot org
  2010-03-16  6:24 ` carrot at google dot com
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: rearnsha at gcc dot gnu dot org @ 2010-02-22 14:10 UTC (permalink / raw)
  To: gcc-bugs



-- 

rearnsha at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug target/43129] Simplify global variable's address loading with option -fpic
  2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
@ 2010-02-20 12:41 ` steven at gcc dot gnu dot org
  2010-02-22 14:10 ` rearnsha at gcc dot gnu dot org
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 14+ messages in thread
From: steven at gcc dot gnu dot org @ 2010-02-20 12:41 UTC (permalink / raw)
  To: gcc-bugs



-- 

steven at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rearnsha at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2010-02-20 12:41:03
               date|                            |


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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2014-02-16 13:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-43129-4@http.gcc.gnu.org/bugzilla/>
2010-10-14 16:33 ` [Bug target/43129] Simplify global variable's address loading with option -fpic stephen.clarke at st dot com
     [not found] ` <201010141633.o9EGXcYL022132@rly04e.srv.mailcontrol.com>
2010-10-14 16:39   ` Ramana Radhakrishnan
2010-10-14 16:40 ` ramana.radhakrishnan at arm dot com
2010-10-14 17:02 ` stephen.clarke at st dot com
2014-02-16 13:15 ` jackie.rosen at hushmail dot com
2010-02-20  8:28 [Bug target/43129] New: " carrot at google dot com
2010-02-20 12:41 ` [Bug target/43129] " steven at gcc dot gnu dot org
2010-02-22 14:10 ` rearnsha at gcc dot gnu dot org
2010-03-16  6:24 ` carrot at google dot com
2010-03-30 14:36 ` ebotcazou at gcc dot gnu dot org
2010-03-31  8:01 ` carrot at google dot com
2010-04-07 15:45 ` rth at gcc dot gnu dot org
2010-04-08 13:32 ` carrot at google dot com
2010-04-11 12:09 ` carrot at google dot com
2010-04-11 12:13 ` carrot at google dot com

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).