From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B8C633858411; Thu, 23 Sep 2021 06:57:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B8C633858411 From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/102452] Structs with flexible array members are not optimized on stack Date: Thu, 23 Sep 2021 06:57:23 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 9.3.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia 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: 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: Thu, 23 Sep 2021 06:57:23 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102452 --- Comment #3 from Andrew Pinski --- get_three after einline w/o USE_FLEX_ARR defined (this is changing the type= to int): : _5 =3D test_2(D)->is_a; if (_5 !=3D 0) goto ; [50.00%] else goto ; [50.00%] : D.3292 =3D *test_2(D); goto ; [100.00%] : _6 =3D test_2(D)->as.b.one; _7 =3D (long int) _6; _8 =3D test_2(D)->as.b.two; _9 =3D (long int) _8; _10 =3D test_2(D)->as.b.three; _11 =3D (long int) _10; D.3292.as.a.one =3D _7; D.3292.as.a.two =3D _9; D.3292.as.a.three =3D _11; : _4 =3D D.3292.as.a.three; return _4; With USE_FLEX_ARR defined to 1: : _5 =3D test_2(D)->is_a; if (_5 !=3D 0) goto ; [50.00%] else goto ; [50.00%] : D.3293 =3D *test_2(D); goto ; [100.00%] : _6 =3D test_2(D)->as.b.one; _7 =3D (long int) _6; ret.as.a.one =3D _7; _8 =3D test_2(D)->as.b.two; _9 =3D (long int) _8; ret.as.a.two =3D _9; _10 =3D test_2(D)->as.b.three; _11 =3D (long int) _10; ret.as.a.three =3D _11; D.3293 =3D ret; ret =3D{v} {CLOBBER}; : _4 =3D D.3293.as.a.three; return _4; as far as I can tell the IR is the same before that, even RSO: D.3293 =3D make_test_a (test_2(D)); [return slot optimization] But it looks in the case of the flex array case, RSO does not actually happ= en.=