public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "rsandifo at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/97588] New: Overzealous SRA of boolean bitfields Date: Tue, 27 Oct 2020 08:43:55 +0000 [thread overview] Message-ID: <bug-97588-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97588 Bug ID: 97588 Summary: Overzealous SRA of boolean bitfields Product: gcc Version: 10.2.1 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: rsandifo at gcc dot gnu.org Target Milestone: --- For the nonsense code (reduced from real code): -------------------------------------------------- struct s { unsigned int foo : 11; unsigned int flag1 : 1; unsigned int bar : 11; unsigned int flag2 : 1; }; void f (int n, int *x, struct s *ptr, struct s flags) { for (int i = 0; i < n; ++i) if (x[i] == 1) flags.flag1 = 1; else if (x[i] == 2) flags.flag2 = 1; else if (x[i] == 3) { if (flags.flag1) *ptr++ = flags; } else if (x[i] == 4) { if (flags.flag2) *ptr++ = flags; } else *ptr++ = flags; } -------------------------------------------------- SRA significantly pessimises the output. At the machine level, each update to flags is usually a simple register OR, bit-test, or move, but SRA instead decides to split flags up into 4 pieces and reassemble it for "*ptr++ = flags" (which in the original code is the hot statement).
next reply other threads:[~2020-10-27 8:43 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-10-27 8:43 rsandifo at gcc dot gnu.org [this message] 2020-10-27 9:05 ` [Bug tree-optimization/97588] " rguenth at gcc dot gnu.org 2021-01-22 18:28 ` jamborm 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-97588-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).