public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
* [Bug tree-optimization/114289] New: Non-optimal assembly for accessing bit-fields in packed structs @ 2024-03-08 22:06 dan at stahlke dot org 2024-03-08 22:10 ` [Bug tree-optimization/114289] " dan at stahlke dot org ` (4 more replies) 0 siblings, 5 replies; 6+ messages in thread From: dan at stahlke dot org @ 2024-03-08 22:06 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114289 Bug ID: 114289 Summary: Non-optimal assembly for accessing bit-fields in packed structs Product: gcc Version: 13.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: dan at stahlke dot org Target Milestone: --- // gcc -O3 -g -Wall -march=haswell -mavx2 // https://godbolt.org/z/Yfb9dnYx4 struct foo { int x:31; } __attribute__((packed)); int fx(struct foo const *o) { return o->x; } Disassembly: movzx eax, BYTE PTR [rdi+1] movzx edx, BYTE PTR [rdi] sal rax, 8 or rax, rdx movzx edx, BYTE PTR [rdi+2] sal rdx, 16 or rdx, rax movzx eax, BYTE PTR [rdi+3] and eax, 127 sal rax, 24 or rax, rdx sal rax, 33 sar rax, 33 ret Compare to clang: mov eax, dword ptr [rdi] add eax, eax sar eax ret ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug tree-optimization/114289] Non-optimal assembly for accessing bit-fields in packed structs 2024-03-08 22:06 [Bug tree-optimization/114289] New: Non-optimal assembly for accessing bit-fields in packed structs dan at stahlke dot org @ 2024-03-08 22:10 ` dan at stahlke dot org 2024-03-08 22:10 ` [Bug middle-end/114289] " pinskia at gcc dot gnu.org ` (3 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: dan at stahlke dot org @ 2024-03-08 22:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114289 Dan Stahlke <dan at stahlke dot org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target|x86_64-linux-gnu | Keywords|missed-optimization | Component|middle-end |tree-optimization --- Comment #1 from Dan Stahlke <dan at stahlke dot org> --- Variants that generate more reasonable results: struct foo { int x:32; } __attribute__((packed)); struct foo { int x:16; } __attribute__((packed)); struct foo { int x:31; }; struct foo { int x:31; } __attribute__((packed, aligned(4))); ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/114289] Non-optimal assembly for accessing bit-fields in packed structs 2024-03-08 22:06 [Bug tree-optimization/114289] New: Non-optimal assembly for accessing bit-fields in packed structs dan at stahlke dot org 2024-03-08 22:10 ` [Bug tree-optimization/114289] " dan at stahlke dot org @ 2024-03-08 22:10 ` pinskia at gcc dot gnu.org 2024-03-08 22:11 ` dan at stahlke dot org ` (2 subsequent siblings) 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-03-08 22:10 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114289 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target| |x86_64-linux-gnu Keywords| |missed-optimization Component|tree-optimization |middle-end --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Part of this is a target issue. Due to the x86_64 backend defining SLOW_BYTE_ACCESS to 0. #define SLOW_BYTE_ACCESS 0 ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/114289] Non-optimal assembly for accessing bit-fields in packed structs 2024-03-08 22:06 [Bug tree-optimization/114289] New: Non-optimal assembly for accessing bit-fields in packed structs dan at stahlke dot org 2024-03-08 22:10 ` [Bug tree-optimization/114289] " dan at stahlke dot org 2024-03-08 22:10 ` [Bug middle-end/114289] " pinskia at gcc dot gnu.org @ 2024-03-08 22:11 ` dan at stahlke dot org 2024-03-08 22:12 ` pinskia at gcc dot gnu.org 2024-03-08 22:13 ` pinskia at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: dan at stahlke dot org @ 2024-03-08 22:11 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114289 --- Comment #3 from Dan Stahlke <dan at stahlke dot org> --- Variants that generate more reasonable results: struct foo { int x:32; } __attribute__((packed)); struct foo { int x:16; } __attribute__((packed)); struct foo { int x:31; }; struct foo { int x:31; } __attribute__((packed, aligned(4))); ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/114289] Non-optimal assembly for accessing bit-fields in packed structs 2024-03-08 22:06 [Bug tree-optimization/114289] New: Non-optimal assembly for accessing bit-fields in packed structs dan at stahlke dot org ` (2 preceding siblings ...) 2024-03-08 22:11 ` dan at stahlke dot org @ 2024-03-08 22:12 ` pinskia at gcc dot gnu.org 2024-03-08 22:13 ` pinskia at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-03-08 22:12 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114289 Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED Resolution|--- |DUPLICATE --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Dup. *** This bug has been marked as a duplicate of bug 66364 *** ^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug middle-end/114289] Non-optimal assembly for accessing bit-fields in packed structs 2024-03-08 22:06 [Bug tree-optimization/114289] New: Non-optimal assembly for accessing bit-fields in packed structs dan at stahlke dot org ` (3 preceding siblings ...) 2024-03-08 22:12 ` pinskia at gcc dot gnu.org @ 2024-03-08 22:13 ` pinskia at gcc dot gnu.org 4 siblings, 0 replies; 6+ messages in thread From: pinskia at gcc dot gnu.org @ 2024-03-08 22:13 UTC (permalink / raw) To: gcc-bugs https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114289 --- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> --- Or it is a dup of bug 55658. Either way dup. ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-03-08 22:13 UTC | newest] Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2024-03-08 22:06 [Bug tree-optimization/114289] New: Non-optimal assembly for accessing bit-fields in packed structs dan at stahlke dot org 2024-03-08 22:10 ` [Bug tree-optimization/114289] " dan at stahlke dot org 2024-03-08 22:10 ` [Bug middle-end/114289] " pinskia at gcc dot gnu.org 2024-03-08 22:11 ` dan at stahlke dot org 2024-03-08 22:12 ` pinskia at gcc dot gnu.org 2024-03-08 22:13 ` 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).