From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 32963385842B; Mon, 13 Sep 2021 02:57:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32963385842B From: "bart.vanassche at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/102294] memset expansion is sometimes slow for small sizes Date: Mon, 13 Sep 2021 02:57:47 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.2.1 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: bart.vanassche at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2021 02:57:47 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102294 --- Comment #7 from Bart Van Assche --- Initializing small data structures via structure assignment is a common approach in the Linux kernel. This is the code gcc generates with the no-sse option applied: (gdb) disas bio_init3 Dump of assembler code for function bio_init3: 0x00000000004011b0 <+0>: mov %rdi,%r8 0x00000000004011b3 <+3>: mov $0xf,%ecx 0x00000000004011b8 <+8>: xor %eax,%eax 0x00000000004011ba <+10>: rep stos %rax,%es:(%rdi) 0x00000000004011bd <+13>: movl $0x1,0x20(%r8) 0x00000000004011c5 <+21>: mov %dx,0x62(%r8) 0x00000000004011ca <+26>: movl $0x1,0x64(%r8) 0x00000000004011d2 <+34>: mov %rsi,0x68(%r8) 0x00000000004011d6 <+38>: ret=20=20=20=20 This is the code clang generates with the no-sse option applied: (gdb) disas bio_init3 Dump of assembler code for function bio_init3: 0x00000000004012c0 <+0>: movq $0x0,0x18(%rdi) 0x00000000004012c8 <+8>: movq $0x0,0x10(%rdi) 0x00000000004012d0 <+16>: movq $0x0,0x8(%rdi) 0x00000000004012d8 <+24>: movq $0x0,(%rdi) 0x00000000004012df <+31>: movl $0x1,0x20(%rdi) 0x00000000004012e6 <+38>: movq $0x0,0x24(%rdi) 0x00000000004012ee <+46>: movq $0x0,0x2c(%rdi) 0x00000000004012f6 <+54>: movq $0x0,0x34(%rdi) 0x00000000004012fe <+62>: movq $0x0,0x3c(%rdi) 0x0000000000401306 <+70>: movq $0x0,0x44(%rdi) 0x000000000040130e <+78>: movq $0x0,0x4c(%rdi) 0x0000000000401316 <+86>: movq $0x0,0x54(%rdi) 0x000000000040131e <+94>: movq $0x0,0x5a(%rdi) 0x0000000000401326 <+102>: mov %dx,0x62(%rdi) 0x000000000040132a <+106>: movl $0x1,0x64(%rdi) 0x0000000000401331 <+113>: mov %rsi,0x68(%rdi) 0x0000000000401335 <+117>: movq $0x0,0x70(%rdi) 0x000000000040133d <+125>: ret=20=20=20=20 Is there any x86_64 CPU on which the latter code runs slower than the forme= r?=