git: dc1467c68df2 - stable/14 - amd64 csu: microoptimize startup

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Tue, 11 Mar 2025 00:59:46 UTC
The branch stable/14 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=dc1467c68df2e9a3bb0b212924b2131950cd1305

commit dc1467c68df2e9a3bb0b212924b2131950cd1305
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2025-03-02 23:54:24 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2025-03-11 00:59:11 +0000

    amd64 csu: microoptimize startup
    
    (cherry picked from commit cb991a228179639cc0568fdd5d4b4b07b6f47b5a)
---
 lib/csu/amd64/crt1_s.S | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/lib/csu/amd64/crt1_s.S b/lib/csu/amd64/crt1_s.S
index f7ea076d94f1..3ceea9289330 100644
--- a/lib/csu/amd64/crt1_s.S
+++ b/lib/csu/amd64/crt1_s.S
@@ -49,15 +49,12 @@ _start:
 #ifdef GCRT
 	subq	$16, %rsp
 #endif
-	movq	%rsi, %rcx
-	movq	%rdi, %rsi		/* argv = ap */
-	addq	$8, %rsi		/* argv += 1 */
-	movq	%rdi, %rdx		/* env = ap */
-	addq	$16, %rdx		/* env += 2 */
-	movslq	(%rdi), %rax
-	movl	%eax, %edi		/* argc = *(long *)(void *)ap */
-	shlq	$3, %rax
-	addq	%rax, %rdx		/* env += argc */
+	movq	%rsi, %rcx		/* cleanup */
+	movslq	(%rdi), %rax		/* long *ap; tmpargc = *ap */
+	leaq	0x8(%rdi), %rsi		/* argv = ap + 1 */
+	leaq	0x10(%rdi, %rax, 8), %rdx /* env = ap + 2 + tmpargc */
+	movl	%eax, %edi		/* argc = tmpargc */
+
 #ifdef PIC
 	/*
 	 * XXX. %rip relative addressing is not intended for use in the