From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 31F6B3858D28; Sun, 26 May 2024 20:41:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 31F6B3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1716756096; bh=s4wqYBb0OImI4zEGdcoJdYrf2YBlf72QN8BoYysjuzs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mQvYcnV7FTW/AMYUlpUGoGo5gYIh/GM4z4OglSfCdVYejnZvSmb2ZjOLomM3h5jmZ PxVjRjZbxfPTOPJQYa9nhKkEnIUQdryTecDBz80sB8+HdmXIsxtQtXwSeteqV5+9HQ lflkl9hwPkFZzd+vrLYJwLmtvIzB1QgvFnod3r4E= From: "pskocik at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/93487] Missed tail-call optimizations Date: Sun, 26 May 2024 20:41:35 +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: NEW 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D93487 --- Comment #5 from Petr Skocik --- Another case of a missed tailcall which might warrant a separate mention: struct big{ long _[10]; }; void takePtr(void *); void takeBigAndPassItsAddress(struct big X){ takePtr(&X); } This should ideally compile to just `lea 8(%rsp), %rdi; jmp takePtr;`. The compiler might be tempted here to use the taking of an address of a loc= al here as a reason not to tail call, and clang misses this optimization too, proba= bly for this reason, but tailcalling here is fine as the particular local here isn't allocated by the function but rather the callee during the call. Icc does do this optimization: https://godbolt.org/z/a6coTzPjz=