[Bug c/101705] New: Missed optimization opportunity when copying lots of bitfields
jengelh at inai dot de
gcc-bugzilla@gcc.gnu.org
Sat Jul 31 13:25:15 GMT 2021
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)
More information about the Gcc-bugs
mailing list