This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/78199] New: [PowerPC] Missing optimization for local-exec TLS model


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

            Bug ID: 78199
           Summary: [PowerPC] Missing optimization for local-exec TLS
                    model
           Product: gcc
           Version: 7.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sebastian.huber@embedded-brains.de
  Target Milestone: ---

The following test case:

extern __thread int i;

extern int s;

int fi(void)
{
        return i;
}

int fs(void)
{
        return s;
}

generates:

powerpc-rtems4.12-gcc -O2 -S -ftls-model=local-exec tls.c -o -
        .file   "tls.c"
        .machine ppc
        .section        ".text"
        .align 2
        .globl fi
        .type   fi, @function
fi:
        addis 9,2,i@tprel@ha
        addi 9,9,i@tprel@l
        lwz 3,0(9)
        blr
        .size   fi, .-fi
        .align 2
        .globl fs
        .type   fs, @function
fs:
        lis 9,s@ha
        lwz 3,s@l(9)
        blr
        .size   fs, .-fs
        .ident  "GCC: (GNU) 7.0.0 20161103 (experimental) [master revision
bad2001:22427cc:8c7ce92980721624d9f2ac6332fe34188d09b851]"

This can be optimized to:

fi:
        lis 9,2,i@tprel@ha
        lwz 9,i@tprel@l(2)
        blr

This issue seems to be target specific, for example:

gcc -O2 -S -ftls-model=local-exec tls.c -o -
        .file   "tls.c"
        .text
        .p2align 4,,15
        .globl  fi
        .type   fi, @function
fi:
.LFB0:
        .cfi_startproc
        movl    %fs:i@tpoff, %eax
        ret
        .cfi_endproc
.LFE0:
        .size   fi, .-fi
        .p2align 4,,15
        .globl  fs
        .type   fs, @function
fs:
.LFB1:
        .cfi_startproc
        movl    s(%rip), %eax
        ret
        .cfi_endproc
.LFE1:
        .size   fs, .-fs
        .ident  "GCC: (GNU) 7.0.0 20161103 (experimental) [master revision
bad2001:22427cc:8c7ce92980721624d9f2ac6332fe34188d09b851]"
        .section        .note.GNU-stack,"",@progbits

However:

gcc -O2 -S -ftls-model=local-exec tls.c -o -
        .file   "tls.c"
        .text
        .p2align 4,,15
        .globl  fi
        .type   fi, @function
fi:
.LFB0:
        .cfi_startproc
        movq    %fs:0, %rax
        movl    i@tpoff(%rax), %eax
        ret
        .cfi_endproc
.LFE0:
        .size   fi, .-fi
        .p2align 4,,15
        .globl  fs
        .type   fs, @function
fs:
.LFB1:
        .cfi_startproc
        movl    s(%rip), %eax
        ret
        .cfi_endproc
.LFE1:
        .size   fs, .-fs
        .ident  "GCC: (SUSE Linux) 4.8.1 20130909 [gcc-4_8-branch revision
202388]"
        .section        .note.GNU-stack,"",@progbits

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]