public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/101705] New: Missed optimization opportunity when copying lots of bitfields
@ 2021-07-31 13:25 jengelh at inai dot de
  2021-07-31 13:25 ` [Bug c/101705] " jengelh at inai dot de
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: jengelh at inai dot de @ 2021-07-31 13:25 UTC (permalink / raw)
  To: gcc-bugs

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)

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

end of thread, other threads:[~2021-08-02  8:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-31 13:25 [Bug c/101705] New: Missed optimization opportunity when copying lots of bitfields jengelh at inai dot de
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

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).