public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "guihaoc at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-111449-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111449

            Bug ID: 111449
           Summary: memcmp (p,q,16) == 0 can be optimized better on ppc64
                    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) == 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

             reply	other threads:[~2023-09-18  2:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-18  2:37 guihaoc at gcc dot gnu.org [this message]
2023-10-23  1:17 ` [Bug target/111449] " cvs-commit at gcc dot gnu.org
2023-10-30  3:03 ` cvs-commit at gcc dot gnu.org
2023-11-17  9:20 ` cvs-commit at gcc dot gnu.org
2023-11-17  9:25 ` guihaoc at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-111449-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).