From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 864FF3858406; Thu, 23 Sep 2021 07:16:28 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 864FF3858406 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/102452] Structs with flexible array members are not optimized on stack Date: Thu, 23 Sep 2021 07:16:28 +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: 9.3.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenther at suse dot de 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 07:16:28 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102452 --- Comment #5 from rguenther at suse dot de --- On Thu, 23 Sep 2021, pinskia at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102452 >=20 > --- Comment #3 from Andrew Pinski --- > get_three after einline w/o USE_FLEX_ARR defined (this is changing the ty= pe to > int): >=20 > : > _5 =3D test_2(D)->is_a; > if (_5 !=3D 0) > goto ; [50.00%] > else > goto ; [50.00%] >=20 > : > D.3292 =3D *test_2(D); > goto ; [100.00%] >=20 > : > _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; >=20 > : > _4 =3D D.3292.as.a.three; > return _4; >=20 > 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%] >=20 > : > D.3293 =3D *test_2(D); > goto ; [100.00%] >=20 > : > _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}; >=20 > : > _4 =3D D.3293.as.a.three; > return _4; >=20 >=20 > 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] >=20 >=20 > But it looks in the case of the flex array case, RSO does not actually ha= ppen. Are you sure it's not SRA behaving differently? The IL inlined early is only showing in later dumps...=