public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/95126] New: Missed opportunity to turn static variables into immediates
@ 2020-05-14 10:16 pskocik at gmail dot com
  2020-05-14 11:47 ` [Bug c/95126] " rguenth at gcc dot gnu.org
                   ` (8 more replies)
  0 siblings, 9 replies; 10+ messages in thread
From: pskocik at gmail dot com @ 2020-05-14 10:16 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 95126
           Summary: Missed opportunity to turn static variables into
                    immediates
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pskocik at gmail dot com
  Target Milestone: ---

Example:

For:

struct small{ short a,b; signed char c; };

void call_func(void)
{
        extern int func(struct small X);
        static struct small const s = { 1,2,0 };
        func(s);
}

clang renders (x86_64):

0000000000000000 <call_func>:
   0:   bf 01 00 02 00          mov    edi,0x20001
   5:   e9 00 00 00 00          jmp    a <call_func+0xa>        6:
R_X86_64_PLT32       func-0x4

whereas gcc renders:

0000000000000000 <call_func>:
   0:   0f b7 3d 00 00 00 00    movzx  edi,WORD PTR [rip+0x0]        # 7
<call_func+0x7>        3: R_X86_64_PC32        .rodata-0x2
   7:   0f b7 05 00 00 00 00    movzx  eax,WORD PTR [rip+0x0]        # e
<call_func+0xe>        a: R_X86_64_PC32        .rodata-0x4
   e:   48 c1 e7 10             shl    rdi,0x10
  12:   48 09 f8                or     rax,rdi
  15:   0f b7 3d 00 00 00 00    movzx  edi,WORD PTR [rip+0x0]        # 1c
<call_func+0x1c>      18: R_X86_64_PC32       .rodata
  1c:   48 c1 e7 20             shl    rdi,0x20
  20:   48 09 c7                or     rdi,rax
  23:   e9 00 00 00 00          jmp    28 <call_func+0x28>      24:
R_X86_64_PLT32      func-0x4


https://gcc.godbolt.org/z/Qxq6Rh

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

end of thread, other threads:[~2022-06-10 13:55 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-14 10:16 [Bug c/95126] New: Missed opportunity to turn static variables into immediates pskocik at gmail dot com
2020-05-14 11:47 ` [Bug c/95126] " rguenth at gcc dot gnu.org
2021-12-13  4:56 ` [Bug middle-end/95126] [9/10/11/12 Regression] " pinskia at gcc dot gnu.org
2021-12-13  5:02 ` pinskia at gcc dot gnu.org
2022-01-21 13:34 ` rguenth at gcc dot gnu.org
2022-02-08  5:38 ` amodra at gmail dot com
2022-02-26 22:07 ` roger at nextmovesoftware dot com
2022-05-27  9:42 ` [Bug middle-end/95126] [10/11/12/13 " rguenth at gcc dot gnu.org
2022-06-04 11:23 ` cvs-commit at gcc dot gnu.org
2022-06-10 13:55 ` roger at nextmovesoftware 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).