From owner-svn-src-head@freebsd.org Mon Sep 17 15:49:36 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 964C510A0A3D; Mon, 17 Sep 2018 15:49:36 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4B25D8111E; Mon, 17 Sep 2018 15:49:36 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 41657130A2; Mon, 17 Sep 2018 15:49:36 +0000 (UTC) (envelope-from mjg@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w8HFnaIv049268; Mon, 17 Sep 2018 15:49:36 GMT (envelope-from mjg@FreeBSD.org) Received: (from mjg@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w8HFnZ0d049266; Mon, 17 Sep 2018 15:49:35 GMT (envelope-from mjg@FreeBSD.org) Message-Id: <201809171549.w8HFnZ0d049266@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mjg set sender to mjg@FreeBSD.org using -f From: Mateusz Guzik Date: Mon, 17 Sep 2018 15:49:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r338713 - in head/lib/libc: amd64/string i386/string X-SVN-Group: head X-SVN-Commit-Author: mjg X-SVN-Commit-Paths: in head/lib/libc: amd64/string i386/string X-SVN-Commit-Revision: 338713 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Sep 2018 15:49:36 -0000 Author: mjg Date: Mon Sep 17 15:49:35 2018 New Revision: 338713 URL: https://svnweb.freebsd.org/changeset/base/338713 Log: amd64: depessimize userspace memcpy/memmove/bcopy The change resembles what was done in r334537 for kernel routines. While here take care of i386 variants. Note that primitives remain suboptimal. Reviewed by: kib (previous version) Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D17167 Modified: head/lib/libc/amd64/string/bcopy.S head/lib/libc/i386/string/bcopy.S Modified: head/lib/libc/amd64/string/bcopy.S ============================================================================== --- head/lib/libc/amd64/string/bcopy.S Mon Sep 17 15:34:19 2018 (r338712) +++ head/lib/libc/amd64/string/bcopy.S Mon Sep 17 15:49:35 2018 (r338713) @@ -66,6 +66,9 @@ ENTRY(bcopy) movsq movq %rdx,%rcx andq $7,%rcx /* any bytes left? */ + jne 2f + ret +2: rep movsb ret @@ -73,11 +76,13 @@ ENTRY(bcopy) addq %rcx,%rdi /* copy backwards. */ addq %rcx,%rsi std - andq $7,%rcx /* any fractional bytes? */ decq %rdi decq %rsi + andq $7,%rcx /* any fractional bytes? */ + je 3f rep movsb +3: movq %rdx,%rcx /* copy remainder by words */ shrq $3,%rcx subq $7,%rsi Modified: head/lib/libc/i386/string/bcopy.S ============================================================================== --- head/lib/libc/i386/string/bcopy.S Mon Sep 17 15:34:19 2018 (r338712) +++ head/lib/libc/i386/string/bcopy.S Mon Sep 17 15:49:35 2018 (r338713) @@ -64,7 +64,7 @@ ENTRY(bcopy) movl %edi,%edx subl %esi,%edx cmpl %ecx,%edx /* overlapping? */ - jb 1f + jb 2f cld /* nope, copy forwards. */ movl %ecx,%edx shrl $2,%ecx /* copy by words */ @@ -72,21 +72,28 @@ ENTRY(bcopy) movsl movl %edx,%ecx andl $3,%ecx /* any bytes left? */ + jne 1f + popl %edi + popl %esi + ret +1: rep movsb popl %edi popl %esi ret -1: +2: addl %ecx,%edi /* copy backwards. */ addl %ecx,%esi std movl %ecx,%edx - andl $3,%ecx /* any fractional bytes? */ decl %edi decl %esi + andl $3,%ecx /* any fractional bytes? */ + je 3f rep movsb +3: movl %edx,%ecx /* copy remainder by words */ shrl $2,%ecx subl $3,%esi