From patchwork Fri Mar 25 22:13:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noah Goldstein X-Patchwork-Id: 52379 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 30FB3388981B for ; Fri, 25 Mar 2022 22:14:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 30FB3388981B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1648246442; bh=yD5ohQBDiC69R2dVaw3l2rOX1J9prgOREipNFKBq/iQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=VecolhML4kzoaOZFBxooANOqsfOkMA7A8dWBPWRLXECSin41tMnqX3HB06mSzTU8I OA97VJrlwOxTZwwaUD2UcwIC6bCCIRBuF1mSFXvpm1YyVOPgL29t6CMqMoN0MpGKec E8l9vcJiAR2gFO6N5uBtj/U/m6hN4c1jWIoyMZ/g= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-io1-xd36.google.com (mail-io1-xd36.google.com [IPv6:2607:f8b0:4864:20::d36]) by sourceware.org (Postfix) with ESMTPS id F3CEF3858D37 for ; Fri, 25 Mar 2022 22:13:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F3CEF3858D37 Received: by mail-io1-xd36.google.com with SMTP id z7so10508116iom.1 for ; Fri, 25 Mar 2022 15:13:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yD5ohQBDiC69R2dVaw3l2rOX1J9prgOREipNFKBq/iQ=; b=6SutZrzufWNZK0uGFSje5CaFbJqoYyddmfMRs3em7q0GG7NwrXa1VCmlie9+vLlpp4 ehAXKizcJPRODWAQgiHZEs5Am/0C5oLjwDm2k98L2C3e1Vk9jlaAyCQWOqnsMcLEOMlw hjWfOjL5GoiQycZDLSjfQisGN/ZTAICNVbwmeI5YBgGZGkOMouakpa4lKg4colQuSVDV rhyD0TTbw1VAqCb756tRDqZDWyagF9J7DUpYGT9aA7PYneTUM3RbQlaeRyq3raqVsgde Bix+OxPcC1FF01YLTOi5g7RQO97N3pgs2Rh11O/Zv2tUS+Qnq2f/lS5tHk1SL1wxA+47 TfYw== X-Gm-Message-State: AOAM5316H64WtW20LTzn6+65h5J/w/33V9369oYPgKhpkJ7AbnX0yr51 gdlua92pAoZw8XnHq3i9AgCLtcEftIQ= X-Google-Smtp-Source: ABdhPJw6rW0VkD8MenqL6JIl2OdcCbIZMOelJcX48zQOyhiR9n737zJhu8JZF15rHeYvqklrmin0Lg== X-Received: by 2002:a05:6602:22da:b0:645:ec83:6393 with SMTP id e26-20020a05660222da00b00645ec836393mr600778ioe.165.1648246418993; Fri, 25 Mar 2022 15:13:38 -0700 (PDT) Received: from localhost.localdomain (node-17-161.flex.volo.net. [76.191.17.161]) by smtp.googlemail.com with ESMTPSA id k1-20020a056e021a8100b002c64cf94399sm3784845ilv.44.2022.03.25.15.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 15:13:38 -0700 (PDT) To: libc-alpha@sourceware.org Subject: [PATCH v1 1/2] x86: Small improvements for wcscpy-ssse3 Date: Fri, 25 Mar 2022 17:13:32 -0500 Message-Id: <20220325221333.3079015-1-goldstein.w.n@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_NUMSUBJECT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Noah Goldstein via Libc-alpha From: Noah Goldstein Reply-To: Noah Goldstein Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" Just a few small QOL changes. 1. Prefer `add` > `lea` as it has high execution units it can run on. 2. Don't break macro-fusion between `test` and `jcc` geometric_mean(N=20) of all benchmarks New / Original: 0.973 All string/memory tests pass. Reviewed-by: H.J. Lu --- sysdeps/x86_64/multiarch/wcscpy-ssse3.S | 194 ++++++++++++------------ 1 file changed, 97 insertions(+), 97 deletions(-) diff --git a/sysdeps/x86_64/multiarch/wcscpy-ssse3.S b/sysdeps/x86_64/multiarch/wcscpy-ssse3.S index 34b09af327..aa2b9d030f 100644 --- a/sysdeps/x86_64/multiarch/wcscpy-ssse3.S +++ b/sysdeps/x86_64/multiarch/wcscpy-ssse3.S @@ -52,7 +52,7 @@ ENTRY (__wcscpy_ssse3) jnz L(CopyFrom1To16Bytes) mov %rdx, %rax - lea 16(%rdx), %rdx + addq $16, %rdx and $-16, %rdx sub %rdx, %rax sub %rax, %rcx @@ -75,55 +75,55 @@ L(Align16Both): movaps 16(%rcx), %xmm2 movaps %xmm1, (%rdx) pcmpeqd %xmm2, %xmm0 - pmovmskb %xmm0, %rax - lea 16(%rsi), %rsi + pmovmskb %xmm0, %eax + addq $16, %rsi - test %rax, %rax + test %eax, %eax jnz L(CopyFrom1To16Bytes) movaps 16(%rcx, %rsi), %xmm3 movaps %xmm2, (%rdx, %rsi) pcmpeqd %xmm3, %xmm0 - pmovmskb %xmm0, %rax - lea 16(%rsi), %rsi + pmovmskb %xmm0, %eax + addq $16, %rsi - test %rax, %rax + test %eax, %eax jnz L(CopyFrom1To16Bytes) movaps 16(%rcx, %rsi), %xmm4 movaps %xmm3, (%rdx, %rsi) pcmpeqd %xmm4, %xmm0 - pmovmskb %xmm0, %rax - lea 16(%rsi), %rsi + pmovmskb %xmm0, %eax + addq $16, %rsi - test %rax, %rax + test %eax, %eax jnz L(CopyFrom1To16Bytes) movaps 16(%rcx, %rsi), %xmm1 movaps %xmm4, (%rdx, %rsi) pcmpeqd %xmm1, %xmm0 - pmovmskb %xmm0, %rax - lea 16(%rsi), %rsi + pmovmskb %xmm0, %eax + addq $16, %rsi - test %rax, %rax + test %eax, %eax jnz L(CopyFrom1To16Bytes) movaps 16(%rcx, %rsi), %xmm2 movaps %xmm1, (%rdx, %rsi) pcmpeqd %xmm2, %xmm0 - pmovmskb %xmm0, %rax - lea 16(%rsi), %rsi + pmovmskb %xmm0, %eax + addq $16, %rsi - test %rax, %rax + test %eax, %eax jnz L(CopyFrom1To16Bytes) movaps 16(%rcx, %rsi), %xmm3 movaps %xmm2, (%rdx, %rsi) pcmpeqd %xmm3, %xmm0 - pmovmskb %xmm0, %rax - lea 16(%rsi), %rsi + pmovmskb %xmm0, %eax + addq $16, %rsi - test %rax, %rax + test %eax, %eax jnz L(CopyFrom1To16Bytes) movaps %xmm3, (%rdx, %rsi) @@ -147,10 +147,10 @@ L(Aligned64Loop): pminub %xmm7, %xmm3 pminub %xmm2, %xmm3 pcmpeqd %xmm0, %xmm3 - pmovmskb %xmm3, %rax - lea 64(%rdx), %rdx - lea 64(%rcx), %rcx - test %rax, %rax + pmovmskb %xmm3, %eax + addq $64, %rdx + addq $64, %rcx + testl %eax, %eax jnz L(Aligned64Leave) movaps %xmm4, -64(%rdx) movaps %xmm5, -48(%rdx) @@ -160,32 +160,32 @@ L(Aligned64Loop): L(Aligned64Leave): pcmpeqd %xmm4, %xmm0 - pmovmskb %xmm0, %rax - test %rax, %rax + pmovmskb %xmm0, %eax + test %eax, %eax jnz L(CopyFrom1To16Bytes) pcmpeqd %xmm5, %xmm0 - pmovmskb %xmm0, %rax + pmovmskb %xmm0, %eax movaps %xmm4, -64(%rdx) - test %rax, %rax - lea 16(%rsi), %rsi + addq $16, %rsi + test %eax, %eax jnz L(CopyFrom1To16Bytes) pcmpeqd %xmm6, %xmm0 - pmovmskb %xmm0, %rax + pmovmskb %xmm0, %eax movaps %xmm5, -48(%rdx) - test %rax, %rax - lea 16(%rsi), %rsi + addq $16, %rsi + test %eax, %eax jnz L(CopyFrom1To16Bytes) movaps %xmm6, -32(%rdx) pcmpeqd %xmm7, %xmm0 - pmovmskb %xmm0, %rax - lea 16(%rsi), %rsi - test %rax, %rax + pmovmskb %xmm0, %eax + addq $16, %rsi + test %eax, %eax jnz L(CopyFrom1To16Bytes) mov $-0x40, %rsi @@ -198,10 +198,10 @@ L(Shl4): movaps 12(%rcx), %xmm2 L(Shl4Start): pcmpeqd %xmm2, %xmm0 - pmovmskb %xmm0, %rax + pmovmskb %xmm0, %eax movaps %xmm2, %xmm3 - test %rax, %rax + test %eax, %eax jnz L(Shl4LoopExit) palignr $4, %xmm1, %xmm2 @@ -209,12 +209,12 @@ L(Shl4Start): movaps 28(%rcx), %xmm2 pcmpeqd %xmm2, %xmm0 - lea 16(%rdx), %rdx - pmovmskb %xmm0, %rax - lea 16(%rcx), %rcx + addq $16, %rdx + pmovmskb %xmm0, %eax + addq $16, %rcx movaps %xmm2, %xmm1 - test %rax, %rax + test %eax, %eax jnz L(Shl4LoopExit) palignr $4, %xmm3, %xmm2 @@ -222,12 +222,12 @@ L(Shl4Start): movaps 28(%rcx), %xmm2 pcmpeqd %xmm2, %xmm0 - lea 16(%rdx), %rdx - pmovmskb %xmm0, %rax - lea 16(%rcx), %rcx + addq $16, %rdx + pmovmskb %xmm0, %eax + addq $16, %rcx movaps %xmm2, %xmm3 - test %rax, %rax + test %eax, %eax jnz L(Shl4LoopExit) palignr $4, %xmm1, %xmm2 @@ -235,22 +235,22 @@ L(Shl4Start): movaps 28(%rcx), %xmm2 pcmpeqd %xmm2, %xmm0 - lea 16(%rdx), %rdx - pmovmskb %xmm0, %rax - lea 16(%rcx), %rcx + addq $16, %rdx + pmovmskb %xmm0, %eax + addq $16, %rcx - test %rax, %rax + test %eax, %eax jnz L(Shl4LoopExit) palignr $4, %xmm3, %xmm2 movaps %xmm2, (%rdx) - lea 28(%rcx), %rcx - lea 16(%rdx), %rdx + addq $28, %rcx + addq $16, %rdx mov %rcx, %rax and $-0x40, %rcx sub %rcx, %rax - lea -12(%rcx), %rcx + addq $-12, %rcx sub %rax, %rdx movaps -4(%rcx), %xmm1 @@ -267,22 +267,22 @@ L(Shl4LoopStart): pminub %xmm5, %xmm7 pminub %xmm6, %xmm7 pcmpeqd %xmm0, %xmm7 - pmovmskb %xmm7, %rax + pmovmskb %xmm7, %eax movaps %xmm5, %xmm7 palignr $4, %xmm4, %xmm5 - test %rax, %rax palignr $4, %xmm3, %xmm4 + test %eax, %eax jnz L(Shl4Start) palignr $4, %xmm2, %xmm3 - lea 64(%rcx), %rcx + addq $64, %rcx palignr $4, %xmm1, %xmm2 movaps %xmm7, %xmm1 movaps %xmm5, 48(%rdx) movaps %xmm4, 32(%rdx) movaps %xmm3, 16(%rdx) movaps %xmm2, (%rdx) - lea 64(%rdx), %rdx + addq $64, %rdx jmp L(Shl4LoopStart) L(Shl4LoopExit): @@ -297,10 +297,10 @@ L(Shl8): movaps 8(%rcx), %xmm2 L(Shl8Start): pcmpeqd %xmm2, %xmm0 - pmovmskb %xmm0, %rax + pmovmskb %xmm0, %eax movaps %xmm2, %xmm3 - test %rax, %rax + test %eax, %eax jnz L(Shl8LoopExit) palignr $8, %xmm1, %xmm2 @@ -308,12 +308,12 @@ L(Shl8Start): movaps 24(%rcx), %xmm2 pcmpeqd %xmm2, %xmm0 - lea 16(%rdx), %rdx - pmovmskb %xmm0, %rax - lea 16(%rcx), %rcx + addq $16, %rdx + pmovmskb %xmm0, %eax + addq $16, %rcx movaps %xmm2, %xmm1 - test %rax, %rax + test %eax, %eax jnz L(Shl8LoopExit) palignr $8, %xmm3, %xmm2 @@ -321,12 +321,12 @@ L(Shl8Start): movaps 24(%rcx), %xmm2 pcmpeqd %xmm2, %xmm0 - lea 16(%rdx), %rdx - pmovmskb %xmm0, %rax - lea 16(%rcx), %rcx + addq $16, %rdx + pmovmskb %xmm0, %eax + addq $16, %rcx movaps %xmm2, %xmm3 - test %rax, %rax + test %eax, %eax jnz L(Shl8LoopExit) palignr $8, %xmm1, %xmm2 @@ -334,22 +334,22 @@ L(Shl8Start): movaps 24(%rcx), %xmm2 pcmpeqd %xmm2, %xmm0 - lea 16(%rdx), %rdx - pmovmskb %xmm0, %rax - lea 16(%rcx), %rcx + addq $16, %rdx + pmovmskb %xmm0, %eax + addq $16, %rcx - test %rax, %rax + test %eax, %eax jnz L(Shl8LoopExit) palignr $8, %xmm3, %xmm2 movaps %xmm2, (%rdx) - lea 24(%rcx), %rcx - lea 16(%rdx), %rdx + addq $24, %rcx + addq $16, %rdx mov %rcx, %rax and $-0x40, %rcx sub %rcx, %rax - lea -8(%rcx), %rcx + addq $-8, %rcx sub %rax, %rdx movaps -8(%rcx), %xmm1 @@ -366,22 +366,22 @@ L(Shl8LoopStart): pminub %xmm5, %xmm7 pminub %xmm6, %xmm7 pcmpeqd %xmm0, %xmm7 - pmovmskb %xmm7, %rax + pmovmskb %xmm7, %eax movaps %xmm5, %xmm7 palignr $8, %xmm4, %xmm5 - test %rax, %rax palignr $8, %xmm3, %xmm4 + test %eax, %eax jnz L(Shl8Start) palignr $8, %xmm2, %xmm3 - lea 64(%rcx), %rcx + addq $64, %rcx palignr $8, %xmm1, %xmm2 movaps %xmm7, %xmm1 movaps %xmm5, 48(%rdx) movaps %xmm4, 32(%rdx) movaps %xmm3, 16(%rdx) movaps %xmm2, (%rdx) - lea 64(%rdx), %rdx + addq $64, %rdx jmp L(Shl8LoopStart) L(Shl8LoopExit): @@ -396,10 +396,10 @@ L(Shl12): movaps 4(%rcx), %xmm2 L(Shl12Start): pcmpeqd %xmm2, %xmm0 - pmovmskb %xmm0, %rax + pmovmskb %xmm0, %eax movaps %xmm2, %xmm3 - test %rax, %rax + test %eax, %eax jnz L(Shl12LoopExit) palignr $12, %xmm1, %xmm2 @@ -407,12 +407,12 @@ L(Shl12Start): movaps 20(%rcx), %xmm2 pcmpeqd %xmm2, %xmm0 - lea 16(%rdx), %rdx - pmovmskb %xmm0, %rax - lea 16(%rcx), %rcx + addq $16, %rdx + pmovmskb %xmm0, %eax + addq $16, %rcx movaps %xmm2, %xmm1 - test %rax, %rax + test %eax, %eax jnz L(Shl12LoopExit) palignr $12, %xmm3, %xmm2 @@ -420,12 +420,12 @@ L(Shl12Start): movaps 20(%rcx), %xmm2 pcmpeqd %xmm2, %xmm0 - lea 16(%rdx), %rdx - pmovmskb %xmm0, %rax - lea 16(%rcx), %rcx + addq $16, %rdx + pmovmskb %xmm0, %eax + addq $16, %rcx movaps %xmm2, %xmm3 - test %rax, %rax + test %eax, %eax jnz L(Shl12LoopExit) palignr $12, %xmm1, %xmm2 @@ -433,22 +433,22 @@ L(Shl12Start): movaps 20(%rcx), %xmm2 pcmpeqd %xmm2, %xmm0 - lea 16(%rdx), %rdx - pmovmskb %xmm0, %rax - lea 16(%rcx), %rcx + addq $16, %rdx + pmovmskb %xmm0, %eax + addq $16, %rcx - test %rax, %rax + test %eax, %eax jnz L(Shl12LoopExit) palignr $12, %xmm3, %xmm2 movaps %xmm2, (%rdx) - lea 20(%rcx), %rcx - lea 16(%rdx), %rdx + addq $20, %rcx + addq $16, %rdx mov %rcx, %rax and $-0x40, %rcx sub %rcx, %rax - lea -4(%rcx), %rcx + addq $-4, %rcx sub %rax, %rdx movaps -12(%rcx), %xmm1 @@ -465,21 +465,21 @@ L(Shl12LoopStart): pminub %xmm5, %xmm7 pminub %xmm6, %xmm7 pcmpeqd %xmm0, %xmm7 - pmovmskb %xmm7, %rax + pmovmskb %xmm7, %eax movaps %xmm5, %xmm7 palignr $12, %xmm4, %xmm5 - test %rax, %rax palignr $12, %xmm3, %xmm4 + test %eax, %eax jnz L(Shl12Start) palignr $12, %xmm2, %xmm3 - lea 64(%rcx), %rcx + addq $64, %rcx palignr $12, %xmm1, %xmm2 movaps %xmm7, %xmm1 movaps %xmm5, 48(%rdx) movaps %xmm4, 32(%rdx) movaps %xmm3, 16(%rdx) movaps %xmm2, (%rdx) - lea 64(%rdx), %rdx + addq $64, %rdx jmp L(Shl12LoopStart) L(Shl12LoopExit):