public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jengelh at inai dot de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c/101705] New: Missed optimization opportunity when copying lots of bitfields
Date: Sat, 31 Jul 2021 13:25:15 +0000	[thread overview]
Message-ID: <bug-101705-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 101705
           Summary: Missed optimization opportunity when copying lots of
                    bitfields
           Product: gcc
           Version: 11.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jengelh at inai dot de
  Target Milestone: ---

Using gcc-11.1.1 [revision 62bbb113ae68a7e724255e17143520735bcb9ec9], I observe
that gcc is able to recognize and combine lots of "structb->member =
structa->member" assignments into SIMD instructions. However, this only works
as long as "member" has exactly 8*n bits. It would appear gcc is not smart
enough to consider smaller entities (if and when they add up to multiples of 8
or 64).

Observed
========
[On x86_64]

»gcc -O3 -c 1.c; gcc -O3 -c 2.c
»objdump -d 1.o
   0:   f3 0f 6f 3e             movdqu (%rsi),%xmm7
...
»objdump -d 2.o
   0:   0f b6 16                movzbl (%rsi),%edx
   3:   0f b6 07                movzbl (%rdi),%eax
   6:   83 e2 01                and    $0x1,%edx
   9:   83 e0 fe                and    $0xfffffffe,%eax
   c:   09 d0                   or     %edx,%eax
   e:   88 07                   mov    %al,(%rdi)
  10:   0f b6 16                movzbl (%rsi),%edx
  13:   83 e0 fd                and    $0xfffffffd,%eax
  16:   83 e2 02                and    $0x2,%edx
  19:   09 d0                   or     %edx,%eax
  1b:   88 07                   mov    %al,(%rdi)
...

Expected
========
Emit some movdqu/movups even for 2.c.

Other info
==========
gcc version 11.1.1 20210625 [revision 62bbb113ae68a7e724255e17143520735bcb9ec9]
(SUSE Linux) &
gcc version 7.5.0 (SUSE Linux)

             reply	other threads:[~2021-07-31 13:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-31 13:25 jengelh at inai dot de [this message]
2021-07-31 13:25 ` [Bug c/101705] " jengelh at inai dot de
2021-07-31 13:25 ` jengelh at inai dot de
2021-07-31 19:35 ` [Bug tree-optimization/101705] " pinskia at gcc dot gnu.org
2021-08-02  8:38 ` rguenth 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-101705-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: link
Be 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).