From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 020513851C01; Sat, 27 Jun 2020 16:44:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 020513851C01 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593276269; bh=+Mx7FUx5TrYmMoApRL88HBoYul7n6YS27p5yyROyKA4=; h=From:To:Subject:Date:From; b=XxbdzZvT0amYhs9fdlgW0WvlpFeEImB4GHCiOLTmCAuQIldRj8umwwU8wNAump4VL KRautOutWKXG6tPT0v4i1FAB6q9ub+yDjNC1s69XLlyKpg8HwY0n5wcqrmn1aQQjtR B4vJbZy2NS0RGq+EF+JaRErS2xskAmXp//Qk2dyQ= From: "josephcsible at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/95941] New: Passing a struct by value wastes 16 bytes on the stack Date: Sat, 27 Jun 2020 16:44:28 +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: 10.1.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: josephcsible at gmail dot com 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 keywords bug_severity priority component assigned_to reporter target_milestone cf_gcctarget 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Jun 2020 16:44:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D95941 Bug ID: 95941 Summary: Passing a struct by value wastes 16 bytes on the stack Product: gcc Version: 10.1.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: josephcsible at gmail dot com Target Milestone: --- Target: x86_64-linux-gnu Consider this C code: extern struct foo { long x, y, z; } s; void f(struct foo); void g(void) { f(s); } At "-O3", it compiles to this: g: subq $16, %rsp pushq s+16(%rip) pushq s+8(%rip) pushq s(%rip) call f addq $40, %rsp ret There's no reason at all to use that extra 16 bytes of stack space. It shou= ld have compiled to this instead: g: pushq s+16(%rip) pushq s+8(%rip) pushq s(%rip) call f addq $24, %rsp ret=