From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id DAD9B3858413; Mon, 4 Mar 2024 09:54:57 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DAD9B3858413 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1709546097; bh=Itx+0HJrDuvbLJLbJQZmt2z4jj3WGxfh/hytZ1hBd0U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dL1QUSyOvNmW08P5DZCCpP/ELsM6CrFz5BhQsxX6r+fDo8bd6UMmLoGr77FA+zBcv Q6/6K+NxeB70pxf+REU9uv7XkF0Dro6epU3zKgJNBQfrXQ3Uk8N4InAeLfR7fpfkc4 d/iSsTq5X9l4iS7RDCmTQ5MFnYdCZbAO4UrUPmdA= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/114206] recursive function call vs local variable addresses Date: Mon, 04 Mar 2024 09:54:56 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org 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: bug_status everconfirmed cf_reconfirmed_on 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=3D114206 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Ever confirmed|0 |1 Last reconfirmed| |2024-03-04 --- Comment #6 from Richard Biener --- So we simplify this and RTL expand from int f (int t, const int * a) { const int b[4]; _Bool _1; int _8; [local count: 1073741824]: if (t_3(D) =3D=3D 0) goto ; [49.25%] else goto ; [50.75%] [local count: 528857912]: [local count: 1073741824]: # a_11 =3D PHI _1 =3D &b =3D=3D a_11; _8 =3D (int) _1; b =3D{v} {CLOBBER(eos)}; return _8; We apply tail-recursion optimization here which coalescs both slots which are used just by their address. IIRC tail-recursion analysis uses alias analysis to be able to handle some cases where TREE_ADDRESSABLE vars are passed. We miss considering variables live that are passed by reference (but otherw= ise are "unused"). As you needed to cut off quite some optimizations to early simplify the b =3D=3D a compare this is a bit academic or needs much more obfuscation of= the compare to actually matter. But yes, it's a bug.=