public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/65103] New: [i386] GOTOFF relocation is not propagated into address expression
@ 2015-02-18 11:41 enkovich.gnu at gmail dot com
  2015-03-12 11:27 ` [Bug target/65103] " ienkovich at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: enkovich.gnu at gmail dot com @ 2015-02-18 11:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65103

            Bug ID: 65103
           Summary: [i386] GOTOFF relocation is not propagated into
                    address expression
           Product: gcc
           Version: 5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: enkovich.gnu at gmail dot com

In PIC code there are multiple cases when GOTOFF relocation is put into
register and then used in address expression instead of using relocation
directly in address expression.  Here is an example:

>cat test.c
typedef struct S
{
  int a;
  int sum;
  int delta;
} S;

S gs;
int global_opt (int max)
{
  while (gs.sum < max)
    gs.sum += gs.delta;
  return gs.a;
}
>gcc test.c -m32 -O2 -fPIE -S
>cat test.s
...
        pushl   %esi
        leal    gs@GOTOFF, %esi
        pushl   %ebx
        call    __x86.get_pc_thunk.bx
        addl    $_GLOBAL_OFFSET_TABLE_, %ebx
        movl    12(%esp), %edx
        movl    4(%esi,%ebx), %eax
        cmpl    %eax, %edx
        jle     .L4
        movl    8(%esi,%ebx), %ecx
.L3:
        addl    %ecx, %eax
        cmpl    %eax, %edx
        jg      .L3
        movl    %eax, 4(%esi,%ebx)
.L4:
        movl    gs@GOTOFF(%ebx), %eax
        popl    %ebx
        popl    %esi
        ret

A separate instruction to get gs@GOTOFF is generated in expand.  Later fwprop
propagates this constant only into memory references with zero offset and leave
register usage in all others.

Used compiler:

Target: x86_64-unknown-linux-gnu
Configured with: ../gcc/configure --enable-languages=c,c++,fortran
--disable-bootstrap --prefix=/export/users/ienkovic/ --disable-libsanitizer
Thread model: posix
gcc version 5.0.0 20150217 (experimental) (GCC)


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

* [Bug target/65103] [i386] GOTOFF relocation is not propagated into address expression
  2015-02-18 11:41 [Bug target/65103] New: [i386] GOTOFF relocation is not propagated into address expression enkovich.gnu at gmail dot com
@ 2015-03-12 11:27 ` ienkovich at gcc dot gnu.org
  2015-04-15 17:04 ` LpSolit at netscape dot net
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: ienkovich at gcc dot gnu.org @ 2015-03-12 11:27 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65103

--- Comment #1 from ienkovich at gcc dot gnu.org ---
Author: ienkovich
Date: Thu Mar 12 09:53:36 2015
New Revision: 221380

URL: https://gcc.gnu.org/viewcvs?rev=221380&root=gcc&view=rev
Log:
gcc/

    PR target/65103
    * config/i386/i386.c (ix86_address_cost): Fix cost of a PIC
    register.

gcc/testsuite/

    PR target/65103
    * gcc.target/i386/pr65103-1.c: New.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr65103-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug target/65103] [i386] GOTOFF relocation is not propagated into address expression
  2015-02-18 11:41 [Bug target/65103] New: [i386] GOTOFF relocation is not propagated into address expression enkovich.gnu at gmail dot com
  2015-03-12 11:27 ` [Bug target/65103] " ienkovich at gcc dot gnu.org
@ 2015-04-15 17:04 ` LpSolit at netscape dot net
  2015-05-13  8:29 ` ienkovich at gcc dot gnu.org
  2021-08-16  8:34 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: LpSolit at netscape dot net @ 2015-04-15 17:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65103

--- Comment #1 from Ilya Enkovich <ienkovich at gcc dot gnu.org> ---
Author: ienkovich
Date: Thu Mar 12 09:53:36 2015
New Revision: 221380

URL: https://gcc.gnu.org/viewcvs?rev=221380&root=gcc&view=rev
Log:
gcc/

    PR target/65103
    * config/i386/i386.c (ix86_address_cost): Fix cost of a PIC
    register.

gcc/testsuite/

    PR target/65103
    * gcc.target/i386/pr65103-1.c: New.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr65103-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug target/65103] [i386] GOTOFF relocation is not propagated into address expression
  2015-02-18 11:41 [Bug target/65103] New: [i386] GOTOFF relocation is not propagated into address expression enkovich.gnu at gmail dot com
  2015-03-12 11:27 ` [Bug target/65103] " ienkovich at gcc dot gnu.org
  2015-04-15 17:04 ` LpSolit at netscape dot net
@ 2015-05-13  8:29 ` ienkovich at gcc dot gnu.org
  2021-08-16  8:34 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: ienkovich at gcc dot gnu.org @ 2015-05-13  8:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65103

--- Comment #2 from Ilya Enkovich <ienkovich at gcc dot gnu.org> ---
Author: ienkovich
Date: Wed May 13 08:29:14 2015
New Revision: 223119

URL: https://gcc.gnu.org/viewcvs?rev=223119&root=gcc&view=rev
Log:
gcc/

        PR target/65103
        * config/i386/i386.c (ix86_rtx_costs): We want to propagate
        link time constants into adress expressions and therefore set
        their cost to 0.

gcc/testsuite/

        PR target/65103
        * gcc.target/i386/pr65103-3.c: New.


Added:
    trunk/gcc/testsuite/gcc.target/i386/pr65103-3.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/i386.c
    trunk/gcc/testsuite/ChangeLog


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

* [Bug target/65103] [i386] GOTOFF relocation is not propagated into address expression
  2015-02-18 11:41 [Bug target/65103] New: [i386] GOTOFF relocation is not propagated into address expression enkovich.gnu at gmail dot com
                   ` (2 preceding siblings ...)
  2015-05-13  8:29 ` ienkovich at gcc dot gnu.org
@ 2021-08-16  8:34 ` pinskia at gcc dot gnu.org
  3 siblings, 0 replies; 5+ messages in thread
From: pinskia at gcc dot gnu.org @ 2021-08-16  8:34 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65103

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |missed-optimization
           Severity|normal                      |enhancement

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

end of thread, other threads:[~2021-08-16  8:34 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-18 11:41 [Bug target/65103] New: [i386] GOTOFF relocation is not propagated into address expression enkovich.gnu at gmail dot com
2015-03-12 11:27 ` [Bug target/65103] " ienkovich at gcc dot gnu.org
2015-04-15 17:04 ` LpSolit at netscape dot net
2015-05-13  8:29 ` ienkovich at gcc dot gnu.org
2021-08-16  8:34 ` pinskia at gcc dot gnu.org

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