public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/59710] New: Nios2: Missing gprel optimization
@ 2014-01-07 11:02 sebastian.huber@embedded-brains.de
  2014-11-26  1:48 ` [Bug target/59710] " sandra at codesourcery dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: sebastian.huber@embedded-brains.de @ 2014-01-07 11:02 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 59710
           Summary: Nios2: Missing gprel optimization
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sebastian.huber@embedded-brains.de

The compiler doesn't generate gprel load/store operations for variables
external to the translation unit (this is unlike the PowerPC target for
example).  Consider the following test case:

gprel-ok.c:

int iii;
int jjj = 456;

void gprel_ok(void)
{
        iii = 123;
        jjj = 789;
}

gprel-not-ok.c:

extern int iii;
extern int jjj;

void gprel_not_ok(void)
{
        iii = 123;
        jjj = 789;
}

nios2-elf-gcc -O2 -fno-common -S gprel-ok.c
nios2-elf-gcc -O2 -fno-common -S gprel-not-ok.c

gprel-ok.s:

        .file   "gprel-ok.c"
        .section        .text
        .align  2
        .global gprel_ok
        .type   gprel_ok, @function
gprel_ok:
        movi    r2, 123
        stw     r2, %gprel(iii)(gp)
        movi    r2, 789
        stw     r2, %gprel(jjj)(gp)
        ret
        .size   gprel_ok, .-gprel_ok
        .global jjj
        .section        .sdata,"aws",@progbits
        .align  2
        .type   jjj, @object
        .size   jjj, 4
jjj:
        .long   456
        .global iii
        .section        .sbss,"aws",@nobits
        .align  2
        .type   iii, @object
        .size   iii, 4
iii:
        .zero   4
        .ident  "GCC: (GNU) 4.9.0 20140103 (experimental)"

gprel-not-ok.s:

        .file   "gprel-not-ok.c"
        .section        .text
        .align  2
        .global gprel_not_ok
        .type   gprel_not_ok, @function
gprel_not_ok:
        movi    r3, 123
        movhi   r2, %hiadj(iii)
        addi    r2, r2, %lo(iii)
        stw     r3, 0(r2)
        movi    r3, 789
        movhi   r2, %hiadj(jjj)
        addi    r2, r2, %lo(jjj)
        stw     r3, 0(r2)
        ret
        .size   gprel_not_ok, .-gprel_not_ok
        .ident  "GCC: (GNU) 4.9.0 20140103 (experimental)"


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

end of thread, other threads:[~2015-01-16 19:14 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-07 11:02 [Bug target/59710] New: Nios2: Missing gprel optimization sebastian.huber@embedded-brains.de
2014-11-26  1:48 ` [Bug target/59710] " sandra at codesourcery dot com
2015-01-16  0:44 ` sandra at gcc dot gnu.org
2015-01-16  9:32 ` sebastian.huber@embedded-brains.de
2015-01-16 18:34 ` sandra at codesourcery dot com
2015-01-16 19:04 ` joseph at codesourcery dot com
2015-01-16 19:14 ` sandra 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).