public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "colanderman at gmail dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/55360] New: [TileGX] Passing structure by value on stack needlessly writes to and reads from memory Date: Fri, 16 Nov 2012 20:54:00 -0000 [thread overview] Message-ID: <bug-55360-4@http.gcc.gnu.org/bugzilla/> (raw) http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55360 Bug #: 55360 Summary: [TileGX] Passing structure by value on stack needlessly writes to and reads from memory Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: enhancement Priority: P3 Component: rtl-optimization AssignedTo: unassigned@gcc.gnu.org ReportedBy: colanderman@gmail.com #include <stdint.h> struct bar { uint8_t a, b, c, d; }; struct bla { unsigned long a:8, b:8, c:8, d:8; }; uint64_t bar(struct bar); uint64_t bla(struct bla); uint64_t foo(uint8_t a, uint8_t b, uint8_t c, uint8_t d) { return bar((struct bar) { a, b, c, d }); } uint64_t baz(uint8_t a, uint8_t b, uint8_t c, uint8_t d) { return bla((struct bla) { a, b, c, d }); } when compiled with "gcc -Wall -std=gnu99 -O3 -S pbv.c" produces: .file "pbv.c" .text .align 8 .global foo .type foo, @function foo: .LFB0: .cfi_startproc { st sp, lr .cfi_offset 55, 0 move r29, sp addi r28, sp, -16 } addi sp, sp, -24 .cfi_def_cfa_offset 24 { st r28, r29 addi r11, sp, 21 addi r10, sp, 20 } { st1 r11, r1 addi r11, sp, 22 } { st1 r11, r2 addi r11, sp, 23 } { st1 r10, r0 movei r0, 0 } st1 r11, r3 ld4u r10, r10 { bfins r0, r10, 0, 0+32-1 jal bar } addi r29, sp, 24 ld lr, r29 { addi sp, sp, 24 .cfi_restore 54 .cfi_restore 55 .cfi_def_cfa_offset 0 jrp lr } .cfi_endproc .LFE0: .size foo, .-foo .align 8 .global baz .type baz, @function baz: .LFB1: .cfi_startproc { movei r10, 0 st sp, lr .cfi_offset 55, 0 move r29, sp } { bfins r10, r0, 0, 7 addi r28, sp, -8 } { bfins r10, r1, 8, 8+8-1 addi sp, sp, -16 } .cfi_def_cfa_offset 16 { bfins r10, r2, 16, 16+8-1 st r28, r29 } bfins r10, r3, 24, 24+8-1 { move r0, r10 jal bla } addi r29, sp, 16 ld lr, r29 { addi sp, sp, 16 .cfi_restore 54 .cfi_restore 55 .cfi_def_cfa_offset 0 jrp lr } .cfi_endproc .LFE1: .size baz, .-baz .ident "GCC: (GNU) 4.7.2" .section .note.GNU-stack,"",@progbits My expectation is that the foo and baz should compile identically, and should use the bfins bit-arithmetic functions like baz does, rather than redundant stores and loads to stack like foo does. This is with a vanilla GCC 4.7.2 build on a Tilempower system (roughly CentOS 5.7). The problem does not occur on Debian x86-64 with either GCC 4.4.6 or GCC 4.7.2. Possibly related to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7061 (however that case seems to be fixed in 4.7.2).
next reply other threads:[~2012-11-16 20:54 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-11-16 20:54 colanderman at gmail dot com [this message] 2012-11-16 23:46 ` [Bug rtl-optimization/55360] " hjl.tools at gmail dot com 2012-11-19 18:48 ` colanderman at gmail dot com 2022-11-09 15:59 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-55360-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).