From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7C1413858D31; Mon, 20 Apr 2020 06:07:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7C1413858D31 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1587362835; bh=SEIbYsyiGQmyCC99LK/7jEwNunln7n/zyM9Id+YEzaM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eecqmYbQE5LIteG2nq1PRMjDmJPOpDLRDmsPh4+T5Se3+QU0x8TufPqbW9nYaoIKL jCp0cPc1/TLkJGlwAf4jsZdHVNxYHFvawLbpW5PEDumnmhW3r3Ie+n/UIfZmyolqNK r6YIUKeEfm3EjumNF+EJu6SvQtWVHo+02ZhvHOZk= From: "pskocik at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/93487] Missed tail-call optimizations Date: Mon, 20 Apr 2020 06:07:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 9.2.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: pskocik 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: Message-ID: In-Reply-To: References: 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: Mon, 20 Apr 2020 06:07:15 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D93487 --- Comment #3 from pskocik at gmail dot com --- The gist of this along with https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D= 93540 is "please make trivial aggregates (i.e., aggregates, which are ultimately a native type) a true zero-cost abstraction". I feel like we shouldn't have to pay for `struct Int { int _; };` (or a uni= on of int with some <=3D types) over `int`, but on gcc (contrast with clang), = you effectively have to: ///////////////////// int intfunc(void); int intfuncwrap(void) { return intfunc(); } =3D> jmp 5 ///////////////////// struct Int { int x; }; struct Int intfuncwrap2(void) { return (struct Int){intfunc()}; } =3D> push rax call 6 pop rdx ret ///////////////////// Clang has been doing this right since clang 3 (and Compiler Explorer doesn't have an older version): https://gcc.godbolt.org/z/VSUHs_ . Here's a related, but opposite, example where a trivial (one-member) union = gets optimized better than its contained type when used directly:=20 https://gcc.godbolt.org/z/egXRjJ .=20 These trivial type wrappings shouldn't affect codegen positively or negativ= ely, but they do on gcc.=