From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6F8393858D37; Wed, 28 Jun 2023 11:05:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F8393858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687950342; bh=nhSa9hOExiknXdKV1lTZxFaL6kLEMSFtGe27wZK9ZDs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WI78sqxG2EK9bQo+OMdXY9fEcC5y6bVJpeMd2OV1nOUa8QFRx+6Z5jQ4jmIhAw5Vl AXRuZ09VbZor9Xfpxe8zKLvIUJhbbQw5ISgMDLauk9FqvI/Jqp2aQFq8BeTZUhMjYj P+h8ISC1Iis+1Vd+Bee9YQrgnmqxVyhoTi9gGsbI= From: "ubizjak at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/104610] memcmp () == 0 can be optimized better for avx512f Date: Wed, 28 Jun 2023 11:05:42 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 12.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: ubizjak at gmail dot com X-Bugzilla-Status: NEW 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D104610 --- Comment #21 from Uro=C5=A1 Bizjak --- Just before the patch from Comment #20, the compiler creates (-O2 -mavx): --cut here-- vmovdqa .LC1(%rip), %xmm0 vmovdqa %xmm0, -24(%rsp) vmovdqu (%rdi), %xmm0 vpxor .LC0(%rip), %xmm0, %xmm0 vptest %xmm0, %xmm0 je .L5 .L2: movl $1, %eax testl %eax, %eax sete %al ret .L5: vmovdqu 16(%rdi), %xmm0 vpxor -24(%rsp), %xmm0, %xmm0 vptest %xmm0, %xmm0 jne .L2 xorl %eax, %eax testl %eax, %eax sete %al ret --cut here-- Please note the creative way of returning 0 and 1 ... : movl $1, %eax testl %eax, %eax sete %al ret Even the new code (From comment #20) is unnecessarily convoluted: .L2: movl $1, %eax xorl $1, %eax ret .L5: xorl %eax, %eax xorl $1, %eax ret=