From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5E9213858D38; Mon, 18 Sep 2023 02:37:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5E9213858D38 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1695004639; bh=WERhaA8qQVZMUTIb2TgNO+UV1ep4xxzeQIcpa/lvQgE=; h=From:To:Subject:Date:From; b=KlzhwXcG4AABryDWzgxSGoJKdUz53ZeOJe9emp0p7urGOp9MdZ/hS7K7OU5OO3UoE WxkyZhy5m0uQfJ74OmYJyr6vx9/llr0Z4D+hc6EosTEzFPb1lbHVg023EFHKzF8INR XRhVpexMTFVi6lFTNDlF49qxBIg/ZLaqOZm7wxAU= From: "guihaoc at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/111449] New: memcmp (p,q,16) == 0 can be optimized better on ppc64 with vector comparison instructions Date: Mon, 18 Sep 2023 02:37:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: guihaoc at gcc dot gnu.org 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D111449 Bug ID: 111449 Summary: memcmp (p,q,16) =3D=3D 0 can be optimized better on ppc= 64 with vector comparison instructions Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: guihaoc at gcc dot gnu.org Target Milestone: --- int compare (const char* s1, const char* s2) { return __builtin_memcmp (s1, s2, 16) =3D=3D 0; } trunk outputs ld 10,0(3) ld 9,0(4) cmpd 0,10,9 beq 0,.L6 .L2: li 3,1 cntlzw 3,3 srwi 3,3,5 blr .p2align 4,,15 .L6: ld 10,8(3) ld 9,8(4) li 3,0 cmpd 0,10,9 bne 0,.L2 cntlzw 3,3 srwi 3,3,5 blr Expect to use vector comparison to eliminate branches. lxv 32,0(3) lxv 33,0(4) vcmpequb. 0,0,1 mfcr 3,2 rlwinm 3,3,25,1 blr=