public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/115346] New: [15] Volatile load elimination with packed struct bitfields at -O2
@ 2024-06-04 17:11 patrick at rivosinc dot com
  2024-06-04 17:24 ` [Bug middle-end/115346] [15] Volatile load elimination with packed struct bitfields pinskia at gcc dot gnu.org
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: patrick at rivosinc dot com @ 2024-06-04 17:11 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 115346
           Summary: [15] Volatile load elimination with packed struct
                    bitfields at -O2
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: patrick at rivosinc dot com
  Target Milestone: ---

Testcase:
#pragma pack(1)
struct a {
  unsigned b;
  long c : 33;
  unsigned d : 31;
};
volatile struct a h[40];
int main() {
  for (int i = 0; i < 40; i++) {
    h[0];
  }
}

-O3 asm output:
main:
        xor     eax, eax
        ret
h:
        .zero   480

Removing the pack pragma causes the loads to be emitted.

Godbolt: https://godbolt.org/z/3YfrbzdPz
GCC 4.0.4 does not eliminate the loads: https://godbolt.org/z/frsP8o7YT

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

end of thread, other threads:[~2024-06-05  7:01 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-04 17:11 [Bug middle-end/115346] New: [15] Volatile load elimination with packed struct bitfields at -O2 patrick at rivosinc dot com
2024-06-04 17:24 ` [Bug middle-end/115346] [15] Volatile load elimination with packed struct bitfields pinskia at gcc dot gnu.org
2024-06-04 17:30 ` pinskia at gcc dot gnu.org
2024-06-04 17:36 ` pinskia at gcc dot gnu.org
2024-06-05  7:01 ` rguenth 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).